Skip to content

Commit d5434c8

Browse files
TypeScript Botjakebailey
TypeScript Bot
andauthored
🤖 Pick PR #59300 (Verify that perf_hooks result actua...) into release-5.5 (#59301)
Co-authored-by: Jake Bailey <[email protected]>
1 parent f0e9921 commit d5434c8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎src/compiler/performanceCore.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ function tryGetPerformance() {
3131
if (isNodeLikeSystem()) {
3232
try {
3333
// By default, only write native events when generating a cpu profile or using the v8 profiler.
34-
const { performance } = require("perf_hooks") as typeof import("perf_hooks");
35-
return {
36-
shouldWriteNativeEvents: false,
37-
performance,
38-
};
34+
// Some environments may polyfill this module with an empty object; verify the object has the expected shape.
35+
const { performance } = require("perf_hooks") as Partial<typeof import("perf_hooks")>;
36+
if (performance) {
37+
return {
38+
shouldWriteNativeEvents: false,
39+
performance,
40+
};
41+
}
3942
}
4043
catch {
4144
// ignore errors

0 commit comments

Comments
 (0)