deno
59674715 - fix(ext/node): avoid panic deserializing empty buffers over child_process IPC (#35340)

Commit
125 days ago
fix(ext/node): avoid panic deserializing empty buffers over child_process IPC (#35340) ## Summary Sending an empty typed array or `Buffer` (e.g. `Buffer.alloc(0)`) over a `node:child_process` IPC channel with `serialization: "advanced"` panicked the runtime: ``` thread 'main' panicked at ext/node/ops/ipc.rs:596:35: called `Option::unwrap()` on a `None` value ``` A zero-length `ArrayBuffer` has a null backing store, so v8's `ArrayBuffer::data()` returns `None`. The advanced IPC deserializer (`read_host_object`) called `.unwrap()` on it unconditionally before `std::ptr::copy`, so any empty buffer crossing the IPC boundary crashed the worker process. This is what crashed Metro's `jest-worker` child processes when running Expo SDK 54 through Deno's npm compatibility — the worker panics, Metro returns a 500 JSON response for the JS bundle, and the browser refuses to execute it (`application/json` MIME type). ## Fix Skip the copy when `byte_length == 0`. The empty `ArrayBuffer` is still constructed and the correct empty typed array / Buffer view is created from it, so the value round-trips correctly without dereferencing a null pointer. ## Test Extended the existing `ipcSerializationAdvanced` unit test (`tests/unit_node/child_process_test.ts`) to round-trip `new Uint8Array([])`, `Buffer.alloc(0)`, and a nested empty buffer over an advanced-serialization IPC channel. Without the fix the child panics; with it the test passes. Closes #35339 Closes denoland/divybot#580 --------- Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading