Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
The fix looks correct to me, and I found nothing that should block a merge.
This machine can't build a heap large enough to hit the real Bun bug, so I tested by replacing node:v8's writeHeapSnapshot with a version that writes nothing. On the base, HeapSnapshot.write reported success and left a 0-byte .heapsnapshot. With this change it fails and removes the file. The error reaches the heap-dump endpoint's Failed to write heap snapshot: … message through cause.cause.message. A normal snapshot still writes and now logs its size. test/heap-dump.test.ts in packages/server passes. tsc --noEmit in packages/util passes; its typecheck script fails on the base too (Script not found "check").
Public API: unchanged. The heap-dump endpoint now returns its existing error where it used to report a false success.
When the server's heap is large, Capture heaps writes a 0-byte
.heapsnapshotand logsheap snapshot writtenwith no error. This change makesHeapSnapshot.writedetect the empty file, remove it, and fail with the reason.node:v8writeHeapSnapshotwrites the result ofBun.generateHeapSnapshot("v8"). When the V8-format output would exceed about 2 GiB, Bun returns an empty string and does not throw (BunObject.cpp, the"v8"branch skips the null check that the"jsc"branch has). Upstream: Stream V8 heap snapshots to a file so snapshots over 2 GiB can be written (today they silently come back empty) oven-sh/bun#46877.statthe file. If it is empty, delete it and fail. The heap-dump endpoint already turns that failure intoFailed to write heap snapshot: …, and the desktop debug manifest records it as the server'serrorentry.flowchart LR A[writeHeapSnapshot] --> B{file size} B -- "> 0" --> C[log bytes, return path] B -- "0" --> D[remove file] --> E["fail: Bun cannot write a V8 heap snapshot over about 2 GiB, and this heap is too large (N MiB used)"]Visual