Skip to content

Commit eab7ad9

Browse files
authored
Add warning to Wrangler if using the Bun runtime and an error is encountered (#8889)
* 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
1 parent 1b434fe commit eab7ad9

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
@@ -328,5 +328,17 @@ describe("wrangler", () => {
328328
Note that there is a newer version of Wrangler available (123.123.123). Consider checking whether upgrading resolves this error."
329329
`);
330330
});
331+
332+
it("should display a warning if Bun is in use", async () => {
333+
const original = process.versions.bun;
334+
process.versions.bun = "v1";
335+
await logPossibleBugMessage();
336+
expect(std.warn).toMatchInlineSnapshot(`
337+
"▲ [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 ...\`
338+
339+
"
340+
`);
341+
process.versions.bun = original;
342+
});
331343
});
332344
});

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)