fix(perf_hooks): improve Node.js perf_hooks compatibility#6107
Merged
petebacondarwin merged 5 commits intomainfrom Feb 19, 2026
Merged
fix(perf_hooks): improve Node.js perf_hooks compatibility#6107petebacondarwin merged 5 commits intomainfrom
petebacondarwin merged 5 commits intomainfrom
Conversation
Add missing constants, stub functions, and Node.js-specific extensions to improve compatibility with code that expects Node.js perf_hooks APIs: - Add 13 missing constants (entry types and milestones) - Add standalone eventLoopUtilization() and timerify() function exports - Add nodeTiming property to the performance object (via Proxy) - Change eventLoopUtilization() to return stub values instead of throwing - Change markResourceTiming() to no-op instead of throwing These changes follow the stub approach (returning default values) rather than throwing errors, which improves compatibility with libraries that check for API existence but may not need the actual functionality.
anonrig
reviewed
Feb 18, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
Per review feedback, moved nodeTiming from TypeScript Proxy wrapper to the C++ Performance class. This makes nodeTiming available on globalThis.performance when the enable_nodejs_perf_hooks_module flag is enabled. Changes: - Added PerformanceNodeTiming class extending PerformanceEntry in C++ - Added nodeTiming property to Performance class (conditional on flag) - Removed Proxy wrapper from TypeScript, now simple re-export - Updated type snapshots with new PerformanceNodeTiming interface
jasnell
reviewed
Feb 18, 2026
Merged
6 tasks
Address PR review feedback: - Change PerformanceNodeTiming properties from prototype to instance properties to match Node.js behavior where Reflect.ownKeys() includes all properties as own properties - Add missing uvMetricsInfo property that returns libuv event loop metrics (stub values since actual metrics aren't available in workerd) - Update toJSON() to include uvMetricsInfo in the output - Regenerate TypeScript definitions
anonrig
reviewed
Feb 19, 2026
JSG_STRUCT value types don't need memory tracking as they are passed by value to/from JavaScript and don't persist as embedder objects.
anonrig
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves Node.js
perf_hookscompatibility by adding missing constants, stub functions, and Node.js-specific extensions.Changes
eventLoopUtilization()andtimerify()function exportsnodeTimingproperty to the performance object exported fromnode:perf_hooksPerformance.eventLoopUtilization()to return stub values instead of throwingPerformance.markResourceTiming()to no-op instead of throwingApproach
These changes follow the stub approach (returning default values) rather than throwing errors, which improves compatibility with libraries that check for API existence but may not need the actual functionality. This aligns with how
timerify()was already implemented.The
nodeTimingproperty is only available on theperformanceobject exported fromnode:perf_hooks, not onglobalThis.performance, keeping it scoped to Node.js compat contexts.Testing
All 20 perf-hooks tests pass, including new tests for:
eventLoopUtilizationandtimerifyfunctionsperformance.nodeTimingperformance.eventLoopUtilization()returning stubsperformance.markResourceTiming()not throwing