Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1541,14 +1541,11 @@ export default abstract class Server<
}
parsedUrl.pathname = normalizeResult.pathname

for (const key of Object.keys(parsedUrl.query)) {
delete parsedUrl.query[key]
}
// Replace the query object instead of loop-deleting every key.
// Using `delete` on object properties mutates V8 hidden classes,
// which de-optimises inline caches on downstream property accesses.
const invokeQuery = getRequestMeta(req, 'invokeQuery')

if (invokeQuery) {
Object.assign(parsedUrl.query, invokeQuery)
}
parsedUrl.query = invokeQuery ? { ...invokeQuery } : {}

finished = await this.normalizeAndAttachMetadata(req, res, parsedUrl)
if (finished) return
Expand Down
7 changes: 5 additions & 2 deletions packages/next/src/shared/lib/loadable.shared-runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ class LoadableSubscription {
if (typeof opts.delay === 'number') {
if (opts.delay === 0) {
this._state.pastDelay = true
} else {
} else if (typeof window !== 'undefined') {
// Skip timers during SSR — the render is synchronous,
// there are no subscribers to notify, and the timers
// would leak in the Node.js process.
this._delay = setTimeout(() => {
this._update({
pastDelay: true,
Expand All @@ -205,7 +208,7 @@ class LoadableSubscription {
}
}

if (typeof opts.timeout === 'number') {
if (typeof opts.timeout === 'number' && typeof window !== 'undefined') {
this._timeout = setTimeout(() => {
this._update({ timedOut: true })
}, opts.timeout)
Expand Down
Loading