fix(node/perf_hooks): stub eventLoopUtilization (#24501)

This PR stubs `perf_hooks.eventLoopUtilization` to make the tests of
[hapi](https://github.com/hapijs/hapi) start. Previously, they'd all
error because of this function throwing a not implemented error. This
brings down the test failures in their suite from 982 to 68 failures.
This commit is contained in:
Marvin Hagemeister 2024-07-10 19:47:45 +02:00 committed by GitHub
parent 60668c1e93
commit 26288cf2a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View file

@ -26,8 +26,11 @@ const performance:
"clearMeasures" | "getEntries"
>
& {
// deno-lint-ignore no-explicit-any
eventLoopUtilization: any;
eventLoopUtilization(): {
idle: number;
active: number;
utilization: number;
};
nodeTiming: Record<string, string>;
// deno-lint-ignore no-explicit-any
timerify: any;
@ -37,8 +40,10 @@ const performance:
markResourceTiming: any;
} = {
clearMarks: (markName: string) => shimPerformance.clearMarks(markName),
eventLoopUtilization: () =>
notImplemented("eventLoopUtilization from performance"),
eventLoopUtilization: () => {
// TODO(@marvinhagemeister): Return actual non-stubbed values
return { idle: 0, active: 0, utilization: 0 };
},
mark: (markName: string) => shimPerformance.mark(markName),
measure: (
measureName: string,