-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Type-gen check is broken for multi-worker setups #13196
Description
What versions & operating system are you using?
System:
OS: macOS 15.7.4
CPU: (12) arm64 Apple M4 Pro
Memory: 67.92 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 25.8.0 - /opt/homebrew/bin/node
npm: 11.11.0 - /opt/homebrew/bin/npm
pnpm: 10.30.3 - /opt/homebrew/bin/pnpm
bun: 1.3.10 - /opt/homebrew/bin/bun
Deno: 2.7.2 - /opt/homebrew/bin/deno
npmPackages:
wrangler: ^4.79.0 => 4.79.0
Please provide a link to a minimal reproduction
https://github.com/stillwind-ai/multi-worker-env-repro/tree/1bfba8e2d8fd8e8c0075be4bde51a21d78a4f9c5
Describe the Bug
The wrangler types --check command doesn't work for multi-worker setups.
For example, in the repro repository linked above, if I run pnpm cf-typegen in the worker directory (which runs wrangler types -c ./wrangler.jsonc -c ../durable-object/wrangler.jsonc), the wrangler types --check command will always fail (regardless of whether I supply the extra config using the -c flags or not).
This is because the types --check command ignores the secondary configs supplied completely.
AFAICS, it actually ignores most of the flags it is given and just takes the flags from the command it finds in the worker-configuration.d.ts file:
workers-sdk/packages/wrangler/src/type-generation/helpers.ts
Lines 177 to 197 in 48d83ca
| const { command: wranglerCommand = "", hash: maybeExistingHash } = | |
| existingEnvHeader?.match( | |
| /\/\/ Generated by Wrangler by running `(?<command>.*)` \(hash: (?<hash>[a-zA-Z0-9]+)\)/ | |
| )?.groups ?? {}; | |
| // Note: `yargs` doesn't automatically handle aliases, so we check both forms | |
| const rawArgs = yargs(wranglerCommand).parseSync(); | |
| // Determine what was included based on what headers exist | |
| // If no env header exists, env types were not included (--include-env=false) | |
| // If no runtime header exists, runtime types were not included (--include-runtime=false) | |
| const args = { | |
| includeEnv: existingEnvHeader | |
| ? unsafeParseBooleanString(rawArgs.includeEnv ?? "true") | |
| : false, | |
| includeRuntime: existingRuntimeHeader | |
| ? unsafeParseBooleanString(rawArgs.includeRuntime ?? "true") | |
| : false, | |
| envInterface: (rawArgs.envInterface ?? "Env") as string, | |
| strictVars: unsafeParseBooleanString(rawArgs.strictVars ?? "true"), | |
| } satisfies Record<string, string | number | boolean>; |
However, it just ignores the secondary configs from there as well.
Please provide any relevant error logs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status