Skip to content

Commit

Permalink
fix: friendlier error for when a subdomain hasn't been configured in …
Browse files Browse the repository at this point in the history
…dev mode (#1081)

* fix: friendlier error for when a subdomain hasn't been configured in dev mode

* Create nine-crabs-raise.md
  • Loading branch information
rozenmd authored May 20, 2022
1 parent 1a59efe commit 8070763
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nine-crabs-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix: friendlier error for when a subdomain hasn't been configured in dev mode
16 changes: 15 additions & 1 deletion packages/wrangler/src/dev/remote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ export function useWorker(props: {
// we want to log the error, but not end the process
// since it could recover after the developer fixes whatever's wrong
if ((err as { code: string }).code !== "ABORT_ERR") {
logger.error("Error on remote worker:", err);
// instead of logging the raw API error to the user,
// give them friendly instructions
// for error 10063 (workers.dev subdomain required)
if (err.code === 10063) {
const errorMessage =
"Error: You need to register a workers.dev subdomain before running the dev command in remote mode";
const solutionMessage =
"You can either enable local mode by pressing l, or register a workers.dev subdomain here:";
const onboardingLink = `https://dash.cloudflare.com/${accountId}/workers/onboarding`;
logger.error(
`${errorMessage}\n${solutionMessage}\n${onboardingLink}`
);
} else {
logger.error("Error on remote worker:", err);
}
}
});

Expand Down

0 comments on commit 8070763

Please sign in to comment.