Skip to content

Commit b7eba92

Browse files
V3 Backport [#8889]: Add warning to Wrangler if using the Bun runtime and an error is encountered (#8955)
* fast fail wrangler when Bun detected * add test for bun error * Create cold-donuts-fetch.md * improve changeset * improve changeset * fix rebase * soft fail * fix snapshot * fix v3 backport * clarify messaging --------- Co-authored-by: Samuel Macleod <[email protected]>
1 parent 8bcb257 commit b7eba92

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

.changeset/cold-donuts-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
When Wrangler encounters an error, if the Bun runtime is detected it will now warn users that Wrangler does not officially support Bun.

packages/wrangler/src/__tests__/index.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,5 +334,17 @@ describe("wrangler", () => {
334334
Note that there is a newer version of Wrangler available (123.123.123). Consider checking whether upgrading resolves this error."
335335
`);
336336
});
337+
338+
it("should display a warning if Bun is in use", async () => {
339+
const original = process.versions.bun;
340+
process.versions.bun = "v1";
341+
await logPossibleBugMessage();
342+
expect(std.warn).toMatchInlineSnapshot(`
343+
"▲ [WARNING] Wrangler does not support the Bun runtime. Please try this command again using Node.js via \`npm\` or \`pnpm\`. Alternatively, make sure you're not passing the \`--bun\` flag when running \`bun run wrangler ...\`
344+
345+
"
346+
`);
347+
process.versions.bun = original;
348+
});
337349
});
338350
});

packages/wrangler/src/utils/logPossibleBugMessage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import { fgGreenColor, resetColor } from "./constants";
66
* Write a message to the log that tells the user what they might do after we have reported an unexpected error.
77
*/
88
export async function logPossibleBugMessage() {
9+
if (process.versions.bun) {
10+
logger.warn(
11+
`Wrangler does not support the Bun runtime. Please try this command again using Node.js via \`npm\` or \`pnpm\`. Alternatively, make sure you're not passing the \`--bun\` flag when running \`bun run wrangler ...\``
12+
);
13+
return;
14+
}
915
logger.log(
1016
`${fgGreenColor}%s${resetColor}`,
1117
"If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"

0 commit comments

Comments
 (0)