perf: replace delete with = undefined in request hot paths#91560
Open
benfavre wants to merge 2 commits intovercel:canaryfrom
Open
perf: replace delete with = undefined in request hot paths#91560benfavre wants to merge 2 commits intovercel:canaryfrom
benfavre wants to merge 2 commits intovercel:canaryfrom
Conversation
Collaborator
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Collaborator
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
…classes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
159ff24 to
02e6340
Compare
delete on hot-path objects to preserve V8 hidden classes…ects The query object is exposed to user code (getServerSideProps, middleware, etc.). Setting internal keys to undefined instead of deleting them would leak those keys via Object.keys(), for...in, and Object.entries() — even though the values are undefined. Only keep the change for internal-only objects (request headers, request metadata) where enumeration isn't observable.
benfavre
added a commit
to benfavre/next.js
that referenced
this pull request
Mar 18, 2026
The delete→undefined changes for NEXT_URL header and request-meta are already in PR vercel#91560. Keep only the changes unique to this PR: - parsedUrl.query fresh object replacement (avoids N delete operations) - loadable timer guards during SSR
Contributor
Author
Test Verification
All tests run on the |
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.
Summary
Replace
delete obj.propwithobj.prop = undefinedin server request-handling hot paths where the object is not exposed to user code, to preserve V8 hidden classes.Problem
The
deleteoperator changes an object's hidden class (shape), forcing V8 into slower dictionary mode. TanStack Start saw >50% CPU time reduction in affected methods.Changes
= undefined(safe: IncomingHttpHeaders not exposed to user iteration)NEXT_URLheader cleared with= undefined(safe: internal header)removeRequestMetauses= undefined(safe: internal metadata accessed only viagetRequestMeta())NOT changed (intentionally)
Query object keys (
_rsc,nextInternalLocale,__next_*prefixed params) must usedeletebecause the query object is exposed to user code. Setting toundefinedwould leak internal keys viaObject.keys(),for...in, andObject.entries().Test plan
Generated with Claude Code