Skip to content

fix(workers-shared): guard against undefined user_worker static_routing rules#13668

Merged
for-the-kidz merged 2 commits intomainfrom
bugfix/router-worker-rules-guard
Apr 24, 2026
Merged

fix(workers-shared): guard against undefined user_worker static_routing rules#13668
for-the-kidz merged 2 commits intomainfrom
bugfix/router-worker-rules-guard

Conversation

@for-the-kidz
Copy link
Copy Markdown
Contributor

@for-the-kidz for-the-kidz commented Apr 24, 2026

The router-worker's include-rule evaluation passed config.static_routing.user_worker directly to generateStaticRoutingRuleMatcher, which iterates with for...of. When static_routing was configured but user_worker was undefined, this threw TypeError: rules is not iterable, breaking all requests.

The adjacent asset_worker branch on line 207 already applies ?? []; this brings the user_worker branch into parity.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bugfix with no user facing changes

A picture of a cute animal (not mandatory, but encouraged)
PXL_20230402_194223879 PORTRAIT


Open in Devin Review

The router-worker's include-rule evaluation passed config.static_routing.user_worker
directly to generateStaticRoutingRuleMatcher, which iterates with for...of. When
static_routing was configured but user_worker was undefined, this threw
`TypeError: rules is not iterable`, breaking all requests.

The adjacent asset_worker branch on line 207 already applies `?? []`; this brings
the user_worker branch into parity.

Fixes WC-5014 / Sentry #31445454.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: 31a3a44

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Apr 24, 2026
@workers-devprod workers-devprod requested review from a team and edmundhung and removed request for a team April 24, 2026 15:38
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 24, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/deploy-config
  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

✅ All changesets look good

Summary:

  • fix-router-worker-user-worker-rules-iterable.md: Bug fix (patch) - Clear description of the TypeError fix
  • fix-dev-registry-service-binding-props.md: Bug fix (patch) - Well explained with wrangler.json example
  • dev-tunnel-sharing.md: New feature (minor) - New --tunnel flag with usage example
  • queues-consumer-list-commands.md: New feature (minor) - New queues consumer list commands

All changesets follow the guidelines:

  • Version types are appropriate (patch for bug fixes, minor for features)
  • Descriptions are meaningful and explain user impact
  • No h1/h2/h3 markdown headers
  • Examples provided where helpful

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 24, 2026

The fix is clear and correct. The change is a one-character diff (?? []) that brings user_worker into parity with the asset_worker branch on line 207. The test properly covers the regression scenario. The changeset is well-formed.

LGTM

github run

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 1 additional finding.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 6c91cb2

Comment thread packages/workers-shared/router-worker/tests/index.test.ts Outdated
Comment thread packages/workers-shared/router-worker/src/worker.ts
Comment thread packages/workers-shared/router-worker/src/worker.ts
Copy link
Copy Markdown
Member

@edmundhung edmundhung left a comment

Choose a reason for hiding this comment

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

Looks good. Just one nitpick.

Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Apr 24, 2026
@for-the-kidz for-the-kidz merged commit ef24ff2 into main Apr 24, 2026
74 of 77 checks passed
@for-the-kidz for-the-kidz deleted the bugfix/router-worker-rules-guard branch April 24, 2026 19:35
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Apr 24, 2026
vaishnav-mk pushed a commit to vaishnav-mk/workers-sdk that referenced this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants