Conversation
monitorEventLoopDelay() returned the same flat RecordableHistogram as createHistogram(), so user code could inject fake samples into the event-loop-delay histogram via .record() and RecordableHistogram.add() accepted an ELD histogram where Node throws ERR_INVALID_ARG_TYPE. The native prototype is now split into a read-only Histogram base and a RecordableHistogram subclass that alone carries record/recordDelta/add. monitorEventLoopDelay() instances use a separate structure rooted at the base and get an ELDHistogram prototype (enable/disable/Symbol.dispose) layered on in JS. A HistogramKind tag on each instance lets record/recordDelta/add reject a non-recordable receiver with ERR_INVALID_THIS and add() reject a non-recordable argument with ERR_INVALID_ARG_TYPE. add() now returns undefined and the toStringTag is dropped so both kinds stringify as [object Object].
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
WalkthroughIntroduces a ChangesHistogram kind refactor
Compact metadata
Suggested labels: Suggested reviewers: maintainers familiar with JSC bindings and perf_hooks internals 🐰 A histogram once was one shape alone, 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Updated 6:05 AM PT - Jul 7th, 2026
❌ @robobun, your commit ba6a780 has some failures in 🧪 To try this PR locally: bunx bun-pr 33587That installs a local version of the PR into your bun-33587 --bun |
|
CI status: every test lane that ran passed (alpine, debian incl. x64-asan, darwin-26-aarch64, windows, freebsd builds). The two red checks are No |
|
Closing as part of a cleanup of stale pull requests. This PR has had no new commits since 2026-07-07, it conflicts with main, and its last CI run failed. This is not a judgment on the fix itself. If the problem still reproduces on a current build, reopen this PR after a rebase or open a new one against main. |
Repro
Bun 1.4.0 and current main put every Histogram method on one prototype, so the
monitorEventLoopDelay()result exposesrecord/recordDelta/addandRecordableHistogram.prototype.addaccepts it as an argument. Node's hierarchy keeps the event-loop-delay histogram read-only so its samples can only come from the timer.Cause
JSNodePerformanceHooksHistogramhad a single prototype carrying both the read-only stat surface and the mutation methods, andjsFunction_monitorEventLoopDelayallocated with the same structure ascreateHistogram.add()accepted any native histogram instance and returned the dropped-sample count.Fix
JSNodePerformanceHooksHistogramPrototypekeeps the read-only getters plusreset/percentile/percentileBigInt; a newJSNodePerformanceHooksRecordableHistogramPrototype(chained to the base) ownsrecord/recordDelta/add. TheSymbol.toStringTagis dropped so both variants stringify as[object Object].HistogramKind { Recordable, Interval }to the instance.record/recordDelta/addreject a non-recordable receiver withERR_INVALID_THIS;add()rejects a non-recordable argument withERR_INVALID_ARG_TYPE("other", "RecordableHistogram", …)and returnsundefined.m_JSNodePerformanceHooksIntervalHistogramStructuresojsFunction_monitorEventLoopDelayallocates with a structure whose prototype is the read-only base.monitorEventLoopDelay.tsbuilds anELDHistogramprototype (enable/disable/Symbol.dispose) on top of the base and installs it on the native instance, givingeld.constructor.name === "ELDHistogram"and theELDHistogram -> Histogram -> Objectchain.RecordableHistogramsocreateHistogram().constructor.namematches Node.Verification
The new
class hierarchydescribe block fails on released Bun 1.4.0: