Skip to content

[wrangler] Fix type-gen check for multi-worker setups#13273

Open
travisbreaks wants to merge 1 commit intocloudflare:mainfrom
travisbreaks:fix/type-gen-check-multi-worker
Open

[wrangler] Fix type-gen check for multi-worker setups#13273
travisbreaks wants to merge 1 commit intocloudflare:mainfrom
travisbreaks:fix/type-gen-check-multi-worker

Conversation

@travisbreaks
Copy link
Copy Markdown

@travisbreaks travisbreaks commented Apr 5, 2026

Fixes #13196.

The wrangler types --check command was broken for multi-worker setups. When multiple config files were passed via -c flags, the --check code path returned early before building secondary worker entries. This meant generateEnvTypes always received an empty secondaryEntries map, producing a hash that never matched the originally generated types (which did include cross-worker information).

The fix moves secondary entry resolution before the --check early return and passes the entries through to checkTypesUpToDate, which now forwards them to generateEnvTypes for accurate hash comparison.

Changes

  • index.ts: Moved the secondaryEntries building block before the args.check branch so that secondary worker configs are resolved regardless of whether --check is used
  • helpers.ts: Added an optional secondaryEntries parameter to checkTypesUpToDate (defaults to an empty map for backward compatibility) and passes it to generateEnvTypes instead of a hardcoded empty map

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: existing type-generation tests (120 tests) all pass; the change is a straightforward reordering of existing logic with no new branches
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this is a bug fix with no API surface changes

Open with Devin

The `wrangler types --check` command ignored secondary worker configs
passed via multiple `-c` flags. The staleness check ran before
secondary entries were built, so `generateEnvTypes` always received
an empty map. This produced a different hash than the original
generation, causing the check to always report types as out of date.

Move secondary entry resolution before the `--check` early return
and thread the entries through to `checkTypesUpToDate`, which now
forwards them to `generateEnvTypes` for accurate hash comparison.

Fixes cloudflare#13196

Co-Authored-By: Tadao <tadao@travisfixes.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 5, 2026

🦋 Changeset detected

Latest commit: e444dbb

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

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

@workers-devprod workers-devprod requested review from a team and removed request for a team April 5, 2026 02:37
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/type-generation/helpers.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/type-generation/index.ts: [@cloudflare/wrangler]

@workers-devprod workers-devprod requested a review from penalosa April 5, 2026 02:37
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but could do with a unit test—would you be able to add one?

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 13, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: e444dbb

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.

Type-gen check is broken for multi-worker setups

3 participants