Skip to content

run_worker_first: document the 100-entry limit, and that it counts entries rather than distinct patterns #32977

Description

@oddharsh

Which page

https://developers.cloudflare.com/workers/static-assets/routing/worker-script/ (and the other pages that document run_worker_first)

What's missing

run_worker_first accepts at most 100 entries. Go over it and Wrangler refuses to start the Worker at all:

Error: Too many `run_worker_first` rules were provided;
102 rules provided exceeds max of 100.

The limit isn't on that page, and searching the docs for the error text returns nothing.

The part that costs the most time

The cap counts entries, not distinct patterns. A config with duplicates fails on its raw length, so deduplicating buys you room and the error message gives no hint that it would.

Measured on wrangler 4.125.0, wrangler deploy --dry-run:

entries distinct patterns exit message
100 100 0 starts fine
102 102 1 102 rules provided exceeds max of 100
104 99 1 104 rules provided exceeds max of 100

That third row is the one worth documenting. 99 distinct patterns, rejected for carrying 104 entries.

Suggested addition

A line on the run_worker_first docs saying the array takes at most 100 entries and that duplicates count toward the limit. Two sentences would cover it.

Worth mentioning the practical remedy too, since it isn't obvious: check whether an existing wildcard already covers the path before adding a rule. Folding eight exact /lens rows into /lens plus /lens/* took one config from 100 to 94 with no behaviour change.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions