[wrangler] fix: warn when named env silently inherits custom_domain routes#13979
Merged
petebacondarwin merged 8 commits intoJun 3, 2026
Conversation
🦋 Changeset detectedLatest commit: 5cd92bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
@cloudflare/wrangler-bundler
commit: |
64b1a77 to
3aaa4ed
Compare
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
petebacondarwin
requested changes
Jun 1, 2026
petebacondarwin
left a comment
Contributor
There was a problem hiding this comment.
Small suggestion, giving the user the option of hiding the warning.
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
petebacondarwin
approved these changes
Jun 3, 2026
f2ad31a to
9fac7c6
Compare
workers-devprod
approved these changes
Jun 3, 2026
workers-devprod
left a comment
Contributor
There was a problem hiding this comment.
Codeowners reviews satisfied
…outes When an env block does not override `routes`, it inherits the top-level routes array. If that array contains custom_domain:true entries, each deploy to the named env reassigns the custom domain away from the top-level Worker, causing routing drift. Wrangler now emits a warning in this situation and suggests adding `"routes": []` to the env block to prevent inheritance. Fixes cloudflare#13925
- Remove conventional commit prefix from changeset title (violates AGENTS.md rule) - Make envName optional in validateRoutes (undefined = top level) to avoid magic string sentinel - Use topLevelEnv === undefined to detect top-level env at call site (cleaner than string comparison) - Simplify customDomains map with a type predicate to eliminate redundant type checks
Import CustomDomainRoute and use it directly in the type predicate to fix TS2677 error. CustomDomainRoute has `custom_domain: boolean` (required) and `pattern: string`, satisfying the type predicate constraint.
… custom domain inheritance warning Refactor the custom domain check to filter once into a variable rather than scanning the routes array twice. The `r !== null` guard is redundant alongside `typeof r === "object"` but harmless; keeping it satisfies the type predicate.
Add "or copy the route configuration from the top level to hide this warning." to the custom domain inheritance warning, so users have two actionable choices (suppress via empty routes, or explicitly copy).
9fac7c6 to
78307a6
Compare
Contributor
|
@matingathani - unfortunately the formatting is off |
Contributor
Author
|
Fixed the formatting in 44bfd4f. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13925.
When an
env.<name>block does not overrideroutes, it inherits the top-levelroutesarray. If that array contains entries withcustom_domain: true, every deploy to the named environment silently reassigns the custom domain away from the top-level Worker, causing routing drift that is very hard to diagnose.Changes
validateRoutes()inpackages/workers-utils/src/config/validation.tsto emit a warning when:routesroutescontains at least one{ custom_domain: true }entry"routes": []to the env block to prevent inheritanceExample warning