Skip to content

fix(wrangler): derive nodejsCompatMode from the effective compatibility inputs in unstable_startWorker#14617

Draft
martijnwalraven wants to merge 1 commit into
cloudflare:mainfrom
martijnwalraven:callboard/dev-nodejs-compat-default
Draft

fix(wrangler): derive nodejsCompatMode from the effective compatibility inputs in unstable_startWorker#14617
martijnwalraven wants to merge 1 commit into
cloudflare:mainfrom
martijnwalraven:callboard/dev-nodejs-compat-default

Conversation

@martijnwalraven

Copy link
Copy Markdown
Contributor

Makes unstable_startWorker() honor a worker's nodejs_compat compatibility flag, the way wrangler dev does.

The gap. The CLI derives the node-compat mode from the effective compatibility values — input overrides first, then the config file (validateNodeCompatMode(args.compatibilityDate ?? parsedConfig.compatibility_date, args.compatibilityFlags ?? parsedConfig.compatibility_flags ?? [], { noBundle: args.noBundle ?? parsedConfig.no_bundle }) in start-dev.ts). The programmatic path used input.build.nodejsCompatMode raw, so leaving it unset silently ignored the worker's nodejs_compat flag — whether it came from the worker's config file or from input-level compatibilityFlags — and bundling failed to resolve node:* builtins that wrangler dev on the same configuration handles.

The change. When the caller provides no build.nodejsCompatMode, resolveConfig derives it from the same effective values the rest of the resolution uses: input.compatibilityDate ?? config.compatibility_date, input.compatibilityFlags ?? config.compatibility_flags ?? [], and no-bundle from the resolved bundle semantics (!(input.build?.bundle ?? !config.no_bundle) — the programmatic spelling of the CLI's --no-bundle). An explicit value — including null to disable — is still unwrapped exactly as before, so callers owning the mode keep it.

Tests: derived "v2" from a config file carrying compatibility_date + nodejs_compat; derived "v2" from input-level compatibilityFlags over a config file without the flag; explicit null preserved.


  • Tests
    • Tests included (ConfigController: derived from config file / derived from input-level flags / explicit null preserved)
  • Public documentation
    • Documentation not necessary because: bug fix aligning the programmatic dev path with the CLI's compatibility handling; no API surface change. A changeset is included.

🤖 Generated with Claude Code

…ty inputs in startWorker

The CLI feeds validateNodeCompatMode the effective values (args.* ??
parsedConfig.*); the programmatic path used input.build.nodejsCompatMode
raw, so an unset mode ignored the worker's nodejs_compat flag whether it
came from the config file or from input-level compatibilityFlags.
Derive it the same way: input-level compatibilityDate/compatibilityFlags
first, then the resolved config, with noBundle taken from the resolved
build.bundle semantics. An explicit null still disables.
@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c1a3527

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14617

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14617

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14617

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14617

miniflare

npm i https://pkg.pr.new/miniflare@14617

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14617

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14617

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14617

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14617

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14617

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14617

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14617

wrangler

npm i https://pkg.pr.new/wrangler@14617

commit: c1a3527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants