mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Verify that perf_hooks result actually contains the performance object (#59300)
This commit is contained in:
parent
ec446b6f19
commit
bd54a6bb2b
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user