Workers SDK Issue Reports

← Back to Dashboard

#10539 wrangler dev --env doesn't apply to all workers started

Recommendation:KEEP OPEN
Difficulty:easy
Reasoning:

Bug confirmed in source code: secondary workers in multi-worker dev mode don't receive args.env because only disableDevRegistry/multiworkerPrimary are passed to setupDevEnv.

Suggested Action:

Fix start-dev.ts to pass env and envFile to secondary worker setupDevEnv calls

Analysis Report

Issue Review: cloudflare/workers-sdk#10539

Summary

Multi-worker wrangler dev doesn't pass --env flag to secondary workers, causing environment mismatches.

Findings

  • Created: 2025-09-02
  • Updated: 2025-09-02
  • Version: 4.33.2 (reported) → 4.60.0 (current)
  • Component: wrangler dev (multi-worker mode)
  • Labels: bug
  • Comments: 0

Key Evidence

  • No related PRs found: No merged PRs reference issue #10539 or explicitly fix this behavior.
  • Not in changelog: Issue number not mentioned in wrangler CHANGELOG.md.
  • Bug confirmed in source code: In packages/wrangler/src/dev/start-dev.ts, when setting up secondary DevEnvs (lines 96-107), only disableDevRegistry and multiworkerPrimary are passed to setupDevEnv, while the primary worker receives the full ...args spread which includes the env property.

Code showing the bug:

// Primary worker - receives ALL args including env (line 90-94):
await setupDevEnv(primaryDevEnv, args.config[0], authHook, {
  ...args,
  multiworkerPrimary: true,
});

// Secondary workers - MISSING env and other args (lines 102-107):
return setupDevEnv(auxDevEnv, c, authHook, {
  disableDevRegistry: args.disableDevRegistry,
  multiworkerPrimary: false,
});

The setupDevEnv function explicitly uses args.env (line 201) to set the environment, but secondary workers receive an empty/undefined value for this property.

Recommendation

Status: KEEP OPEN

Reasoning: This is a confirmed bug in the source code. The --env flag is not being passed to secondary workers in multi-worker dev mode. The fix is straightforward - the secondary worker setupDevEnv call needs to include env: args.env (and potentially other relevant args like envFile).

Action: Keep open. This is a valid bug that needs to be fixed. The fix should be simple: add env: args.env to the object passed to setupDevEnv for auxiliary DevEnvs.

Suggested Fix

// In start-dev.ts, update the auxiliary DevEnv setup:
return setupDevEnv(auxDevEnv, c, authHook, {
  disableDevRegistry: args.disableDevRegistry,
  multiworkerPrimary: false,
  env: args.env,
  envFile: args.envFile,
});

Notes & Feedback (0)

No notes yet.

Add Note