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

Add Warning about browser rendering when running locally #7533

Merged
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/moody-suns-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Add warning about the browser rendering not available on local
17 changes: 17 additions & 0 deletions packages/wrangler/src/__tests__/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,23 @@ describe.sequential("wrangler dev", () => {
});
});

describe("`browser rendering binding", () => {
it("should show error when running locally", async () => {
writeWranglerConfig({
browser: {
binding: "MYBROWSER",
},
});
fs.writeFileSync("index.js", `export default {};`);

await expect(
runWrangler("dev index.js")
).rejects.toThrowErrorMatchingInlineSnapshot(
"[Error: Browser Rendering is not supported locally. Please use `wrangler dev --remote` instead.]"
);
});
});

it("should error helpfully if pages_build_output_dir is set", async () => {
writeWranglerConfig({ pages_build_output_dir: "dist", name: "test" });
await expect(runWrangler("dev")).rejects.toThrowErrorMatchingInlineSnapshot(
Expand Down
15 changes: 15 additions & 0 deletions packages/wrangler/src/api/startDevWorker/ConfigController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,21 @@ async function resolveConfig(
);
}

if (resolved.assets && resolved.dev.remote) {
throw new UserError(
"Cannot use assets in remote mode. Workers with assets are only supported in local mode. Please use `wrangler dev`."
);
}

if (
extractBindingsOfType("browser", resolved.bindings).length &&
!resolved.dev.remote
) {
throw new UserError(
"Browser Rendering is not supported locally. Please use `wrangler dev --remote` instead."
);
}

validateAssetsArgsAndConfig(resolved);

const services = extractBindingsOfType("service", resolved.bindings);
Expand Down
Loading