Skip to content

Commit 79c3b4e

Browse files
committed
fix: actually measure how long loadChunk takes
1 parent d7ce45c commit 79c3b4e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/next/src/server/client-component-renderer-logger.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ export function wrapClientComponentLoader(
2929
},
3030
loadChunk: (...args) => {
3131
const startTime = performance.now()
32-
try {
33-
return ComponentMod.__next_app__.loadChunk(...args)
34-
} finally {
32+
const result = ComponentMod.__next_app__.loadChunk(...args)
33+
// Avoid wrapping `loadChunk`'s result in an extra promise in case something like React depends on its identity.
34+
// We only need to know when it's settled.
35+
result.finally(() => {
3536
clientComponentLoadTimes += performance.now() - startTime
36-
}
37+
})
38+
return result
3739
},
3840
}
3941
}

0 commit comments

Comments
 (0)