Repository navigation
fix(io): send empty UDP datagrams in Bun - #998
Conversation
|
The regressions test should probably be an addition. Either modify it to just add another (empty) message in that test or make a small new regression test just for this |
okss 🫡 |
hey, saw the change request. i thought the latest update covered your feedback, but might be missing something.... could you point me to what still needs changing? |
|
sorry i didn't see that there was alredy a commit |
|
Thanks @vicmcorrea, and sorry again for the stale change request! The empty ping reproduces the Bun crash without the fix and passes with it, and every UDP test passes in the JS and C lanes on top of current main. Merging 🙏 |
Why
UDP.send_towith an empty string crashes on Bun before sending a packet. Bun's FFI rejects a pointer to an empty byte array. Native Bend sends the same zero-byte datagram successfully.i'm evaluating Bend alongside our TypeScript monorepo and found this while checking Bun and native behavior.
What changed
this passes a null pointer when the payload is empty and still calls
sendto. Nonempty payloads keep the existing path.The UDP round-trip test keeps the original
bend-udpping and adds an empty ping through the same helpers. It checks both replies,bend-udp-pongand-pong, including delivery and the sender's return address. Two files changed, six net lines added.Validation
Checked on macOS arm64 with Bun 1.3.11 and clang 23.1.1:
bend-udp-pongand then fails on the empty ping. With the fix, Bun and native C print both expected replies and exit 0.port_bound.bendpass checking and execution under Bun and native C.git diff --checkpassed.Cluster gates were not run.
Run the regression
From this PR's checkout, with Bun on PATH:
The program exits 0 and prints:
With the original Bun backend, it prints the first line and exits 1 with the empty-memory pointer error.