cloudflare / cloudflare/workers-sdk
run_worker_first: the over-limit error should report the distinct count, since duplicates count toward the cap
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 186
Description
### Which Cloudflare product(s) does this pertain to?
Wrangler core
### What versions are you using?
```
wrangler 4.125.0
node v26.7.0
macOS 26 arm64
```
### Describe the request
The `run_worker_first` cap counts array **entries**, not distinct patterns, and the error says only the entry count. So a config that is over the limit purely through duplication reads as needing 4 rules deleted, when deduplicating would clear it with no behaviour change at all.
```
✘ [ERROR] Too many `run_worker_first` rules were provided;
104 rules provided exceeds max of 100.
```
That config has **99 distinct patterns**. Nothing in the message suggests deduplication is even relevant, so the natural next move is to start folding real paths onto wildcards, which changes what the Worker sees.
Measured on 4.125.0 with `wrangler deploy --dry-run`:
| entries | distinct | exit | message |
|--:|--:|--:|---|
| 100 | 100 | 0 | builds |
| 102 | 102 | 1 | `102 rules provided exceeds max of 100` |
| 104 | **99** | 1 | `104 rules provided exceeds max of 100` |
### Suggested change
Include the distinct count when it differs:
```
Too many `run_worker_first` rules were provided; 104 rules provided
(99 distinct) exceeds max of 100. Duplicate entries count toward the limit.
```
That turns a confusing message into a self-solving one, since the fix becomes obvious the moment you can see the two numbers differ.
An adjacent nicety, if it is cheap: naming one of the duplicated patterns. In a config of 100+ rules that have accumulated over time, finding the duplicates by eye is the actual work.
### Why it matters
This config only fails at the boundary, so it tends to be met by someone adding one routine rule to a list they did not write and did not expect to be near a limit. The Worker then refuses to start at all, and the message points away from the cheapest fix.
For what it is worth, in our case the two rules that pushed a config over turned out to be redundant with an existing wildcard, and separately the list had accumulated real duplicates. Deduplicating took it from over the cap to 94 with nothing else changed.
### Disclosure
Written with Claude Code. Every number above came from running the cases shown.
Contributor guide
Research direction
Start in Wrangler core's run_worker_first limit validation and reproduce the reported cases with wrangler deploy --dry-run. Done means the over-limit error reports the distinct count when it differs from the entry count, while preserving the existing cap behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100