Skip to content

Commit 02e6340

Browse files
benfavreclaude
andcommitted
perf: replace delete with undefined assignment to preserve V8 hidden classes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 196ed2b commit 02e6340

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

packages/next/src/server/app-render/strip-flight-headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ import { FLIGHT_HEADERS } from '../../client/components/app-router-headers'
99
*/
1010
export function stripFlightHeaders(headers: IncomingHttpHeaders) {
1111
for (const header of FLIGHT_HEADERS) {
12-
delete headers[header]
12+
headers[header] = undefined
1313
}
1414
}

packages/next/src/server/base-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ export default abstract class Server<
20182018
if (!addedNextUrlToVary) {
20192019
// Remove `Next-URL` from the request headers we determined it wasn't necessary to include in the Vary header.
20202020
// This is to avoid any dependency on the `Next-URL` header being present when preparing the response.
2021-
delete req.headers[NEXT_URL]
2021+
req.headers[NEXT_URL] = undefined
20222022
}
20232023
}
20242024

@@ -2579,7 +2579,7 @@ export default abstract class Server<
25792579
query[NEXT_RSC_UNION_QUERY]
25802580
)
25812581
}
2582-
delete query[NEXT_RSC_UNION_QUERY]
2582+
query[NEXT_RSC_UNION_QUERY] = undefined
25832583

25842584
const options: MatchOptions = {
25852585
i18n: this.i18nProvider?.fromRequest(req, pathname),

packages/next/src/server/next-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ export default class NextNodeServer extends BaseServer<
11191119
await this.render404(req, res, parsedUrl)
11201120
return true
11211121
}
1122-
delete query[NEXT_RSC_UNION_QUERY]
1122+
query[NEXT_RSC_UNION_QUERY] = undefined
11231123

11241124
// If we handled the request, we can return early.
11251125
// For api routes edge runtime

packages/next/src/server/request-meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export function removeRequestMeta<K extends keyof RequestMeta>(
372372
key: K
373373
) {
374374
const meta = getRequestMeta(request)
375-
delete meta[key]
375+
meta[key] = undefined as RequestMeta[K]
376376
return setRequestMeta(request, meta)
377377
}
378378

packages/next/src/server/server-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function filterInternalQuery(
3434
) {
3535
// this is used to pass query information in rewrites
3636
// but should not be exposed in final query
37-
delete query['nextInternalLocale']
37+
query['nextInternalLocale'] = undefined
3838

3939
for (const key in query) {
4040
const isNextQueryPrefix =
@@ -49,7 +49,7 @@ function filterInternalQuery(
4949
isNextInterceptionMarkerPrefix ||
5050
paramKeys.includes(key)
5151
) {
52-
delete query[key]
52+
query[key] = undefined
5353
}
5454
}
5555
}
@@ -398,7 +398,7 @@ export function getServerUtils({
398398
) {
399399
// this is used to pass query information in rewrites
400400
// but should not be exposed in final query
401-
delete query['nextInternalLocale']
401+
query['nextInternalLocale'] = undefined
402402

403403
for (const [key, value] of Object.entries(query)) {
404404
const normalizedKey = normalizeNextQueryParam(key)

0 commit comments

Comments
 (0)