Skip to content
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/cold-donuts-fetch.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions packages/wrangler/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
});
6 changes: 6 additions & 0 deletions packages/wrangler/src/utils/logPossibleBugMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading