Skip to content
Commit Detail

Commit 97cd88f

Author
Pete Bacon Darwin <pbacondarwin@cloudflare.com> 2026-02-27 13:37:59 +0000
Parents
895ae4a
Tree
e5e67d4
fix: add Performance.toJSON() and make setResourceTimingBufferSize() a no-op

Add toJSON() method to the Performance class, returning an object with
timeOrigin to match the W3C spec and Node.js behavior. This prevents
breakage when frameworks or logging libraries call .toJSON() on the
performance object.

Change setResourceTimingBufferSize() from throwing 'not implemented' to
a silent no-op, matching unenv polyfill behavior. Resource timing is not
applicable in Workers, but isomorphic code commonly calls this
defensively and should not break.

Both changes improve compatibility with the unenv polyfill surface,
ensuring that when the enable_global_performance_classes or
enable_nodejs_perf_hooks_module flags are active (causing unenv to defer
to the native performance object), no functionality is lost compared to
what unenv's JS polyfill would have provided.

Files changed