Follow-up to #66, discovered during native worker verification after local commit fc807a4. The bounded exact worker shard passes all10 files (20 native runner tests plus six direct assertion fixtures), with no skips/failures/timeouts. A stronger read-only control exposes a logical gap shared by native Home and current Bun: after posting 0, false, empty string, null, undefined, or NaN, receiveMessageOnPort returns undefined and loses the message. A truthy string works. Node preserves every payload inside an own message property, including undefined and NaN. Existing upstream receive fixture tests objects only. Root cause spans C++ MessagePort::tryTakeMessage (empty queue conflated with undefined payload) and worker_threads.ts using if (!res). Fix must encode presence independently from payload, regenerate an owned worker builtin, and test empty queue separately from every falsy payload plus transferred ports. The current native worker builtin remains external; Home owns only node/url.ts in the incremental builtin manifest. Full worker parity remains open; no source edits for this finding yet. Avoid merely changing !res to ===undefined, which still loses a real undefined message.
Bun parity: preserve falsy receiveMessageOnPort payloads and own worker builtin
#461Implementation underway for #66: Home now generates its current worker_threads builtin alongside a rebuilt Home MessagePort.cpp translation unit. Native synchronous receive returns an own message envelope for every queued value, including undefined, and reserves bare undefined for an empty queue; deserialization exceptions are checked before object construction. The worker source was brought up to the current Bun implementation, including transfer packing/rollback, while fs and other dependency builtins remain explicitly external. Added native main+worker regressions for falsy payloads, FIFO, descriptor/setter safety, cycles, buffers, transferred ports, close, and sync-vs-async consumption; old binary fails the first queued-undefined assertion. Build-time native wrapper signatures are validated against the linked dispatch table. Shared build and broader worker/queue checks are in progress; not yet claiming completion.
Home now owns the generated worker builtin and native MessagePort queue binding as a paired build contract. Main+worker message-presence regression passes undefined/null/false/0/-0/NaN/empty string/BigInt, FIFO, property descriptors, inherited-setter safety, cloning, buffer/port transfers and mixed synchronous/asynchronous consumption. Existing 12 native regressions also pass. Six generator/ABI tests pass, validating exact wrapped C++ callback signatures before any output. Native exit verification exposed a separate per-VM bug now tracked in #463; standalone worker fixture counts remain provisional until its final rerun. Missing close events are separately tracked in #462 with an explicitly failing regression. FileHandle/fs and other dependency builtins remain external: this is incremental ownership, not complete worker parity.
Verified local commit32ddb4171 owns the worker builtin and MessagePort binding, preserving all falsy/undefined payloads with a native presence envelope. Final worker corpus checkpoint:30 passing native tests,3 explicit upstream skips,0 failures,552 assertions across5 files;11 standalone fixtures pass with exit guards proven active after #463. All14 Home native regressions pass;6 generator/ABI tests and3 binding-helper tests pass. Adjacent eval33pass/70asserts and FFI14pass/11skip/0fail/23asserts. #462 remains a separate known failing close-event regression, and fs/events/streams/shared builtin dependencies remain external. This is not full worker or full Bun parity.
Worker close-lifecycle work is implemented locally in 007858c; see #462 for native queue/transfer/GC/teardown details and exact verification. All 15 native regression files pass; focused worker corpus reports 15 pass / 3 upstream skips / 529 assertions, with FileHandle and transfer/terminate standalone exit guards passing. The ported pipe test now explicitly keeps its FinalizationRegistry alive through reporting; targets and assertions are unchanged. Remaining related gaps are split into #465 (general queued task cancellation) and #466 (receive during pending local close). No full worker-ownership claim; external dependencies still remain. Commit publication is pending because normal git push cannot resolve github.com. Parent #66.
Publication gate is now satisfied. 32ddb4171 is reachable on current main and contains the owned worker builtin/native MessagePort presence envelope described above. The recorded verification covers falsy and undefined payload presence, FIFO, descriptors, cloning/transfers, main/worker use, and adjacent native regressions. Later close/inbox lifecycle work is separately published in #462, #466, and #469; broader worker parity remains under #66. Closing this bounded issue as completed.
Sign in to comment on this issue.