diff --git a/.changeset/cold-donuts-fetch.md b/.changeset/cold-donuts-fetch.md new file mode 100644 index 000000000000..500dd97de1a8 --- /dev/null +++ b/.changeset/cold-donuts-fetch.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +When Wrangler encounters an error, if the Bun runtime is detected it will now warn users that Wrangler does not officially support Bun. diff --git a/packages/wrangler/src/__tests__/index.test.ts b/packages/wrangler/src/__tests__/index.test.ts index 3edefbf42340..2189ce285d55 100644 --- a/packages/wrangler/src/__tests__/index.test.ts +++ b/packages/wrangler/src/__tests__/index.test.ts @@ -328,5 +328,17 @@ describe("wrangler", () => { Note that there is a newer version of Wrangler available (123.123.123). Consider checking whether upgrading resolves this error." `); }); + + it("should display a warning if Bun is in use", async () => { + const original = process.versions.bun; + process.versions.bun = "v1"; + await logPossibleBugMessage(); + expect(std.warn).toMatchInlineSnapshot(` + "▲ [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 ...\` + + " + `); + process.versions.bun = original; + }); }); }); diff --git a/packages/wrangler/src/utils/logPossibleBugMessage.ts b/packages/wrangler/src/utils/logPossibleBugMessage.ts index 8eb696138bf0..953763904930 100644 --- a/packages/wrangler/src/utils/logPossibleBugMessage.ts +++ b/packages/wrangler/src/utils/logPossibleBugMessage.ts @@ -6,6 +6,12 @@ import { fgGreenColor, resetColor } from "./constants"; * Write a message to the log that tells the user what they might do after we have reported an unexpected error. */ export async function logPossibleBugMessage() { + if (process.versions.bun) { + logger.warn( + `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 ...\`` + ); + return; + } logger.log( `${fgGreenColor}%s${resetColor}`, "If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"