From 6238d06c5267ac6f0f2b8887b0a71bcd9001b4b0 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 1 Apr 2026 20:16:22 +0100 Subject: [PATCH] [wrangler] Use formatConfigSnippet for compatibility_date warning in dev The compatibility_date warning in getDevCompatibilityDate() hardcoded a TOML-format snippet. Use formatConfigSnippet() instead so the snippet renders correctly for both wrangler.toml and wrangler.json configs. --- .changeset/use-formatConfigSnippet-in-dev-compat-date.md | 7 +++++++ .../wrangler/src/api/startDevWorker/ConfigController.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/use-formatConfigSnippet-in-dev-compat-date.md diff --git a/.changeset/use-formatConfigSnippet-in-dev-compat-date.md b/.changeset/use-formatConfigSnippet-in-dev-compat-date.md new file mode 100644 index 0000000000..d7b311d62c --- /dev/null +++ b/.changeset/use-formatConfigSnippet-in-dev-compat-date.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +fix: use `formatConfigSnippet` for compatibility_date warning in `wrangler dev` + +The compatibility_date warning shown when no date is configured in `wrangler dev` was hardcoded in TOML format. This now uses `formatConfigSnippet` to render the snippet in the correct format (TOML or JSON) based on the user's config file type. diff --git a/packages/wrangler/src/api/startDevWorker/ConfigController.ts b/packages/wrangler/src/api/startDevWorker/ConfigController.ts index e200ef3583..1eab4e6d57 100644 --- a/packages/wrangler/src/api/startDevWorker/ConfigController.ts +++ b/packages/wrangler/src/api/startDevWorker/ConfigController.ts @@ -3,6 +3,7 @@ import path from "node:path"; import { resolveDockerHost } from "@cloudflare/containers-shared"; import { configFileName, + formatConfigSnippet, getDisableConfigWatching, getDockerPath, getLocalWorkerdCompatibilityDate, @@ -484,7 +485,7 @@ function getDevCompatibilityDate( if (config?.configPath && compatibilityDate === undefined) { logger.warn( `No compatibility_date was specified. Using the installed Workers runtime's latest supported date: ${workerdDate}.\n` + - `❯❯ Add one to your ${configFileName(config.configPath)} file: compatibility_date = "${workerdDate}", or\n` + + `❯❯ Add one to your ${configFileName(config.configPath)} file: ${formatConfigSnippet({ compatibility_date: workerdDate }, config.configPath, false).trim()}, or\n` + `❯❯ Pass it in your terminal: wrangler dev [