Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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