Skip to content

Commit

Permalink
🤖 Pick PR #59300 (Verify that perf_hooks result actua...) into releas…
Browse files Browse the repository at this point in the history
…e-5.5 (#59301)

Co-authored-by: Jake Bailey <[email protected]>
  • Loading branch information
TypeScript Bot and jakebailey authored Jul 16, 2024
1 parent f0e9921 commit d5434c8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/compiler/performanceCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ function tryGetPerformance() {
if (isNodeLikeSystem()) {
try {
// By default, only write native events when generating a cpu profile or using the v8 profiler.
const { performance } = require("perf_hooks") as typeof import("perf_hooks");
return {
shouldWriteNativeEvents: false,
performance,
};
// Some environments may polyfill this module with an empty object; verify the object has the expected shape.
const { performance } = require("perf_hooks") as Partial<typeof import("perf_hooks")>;
if (performance) {
return {
shouldWriteNativeEvents: false,
performance,
};
}
}
catch {
// ignore errors
Expand Down

0 comments on commit d5434c8

Please sign in to comment.