Repository navigation
fix(ext/node): fix child_process.send() backpressure return value - #33869
Conversation
When a handle send is pending ACK and subsequent messages are queued, `send()` should return `false` as soon as more than one message is queued (matching Node.js behavior). Previously, Deno used a threshold of 16, which caused `send()` to incorrectly return `true` when the caller should have been signaled to back off.
Uses internal/child_process kChannelHandle with readStop/readStart which is not exposed in Deno.
fibibot
left a comment
There was a problem hiding this comment.
Substance is correct — 1-line backpressure-threshold fix:
- return handleQueue.length < 16;
+ return handleQueue.length === 1;The walkthrough lines up with Node's lib/internal/child_process.js semantics for send()'s return value:
- 1st
send(msg)while queue is empty → push pushes msg in, queue length is now 1 → returnstrue(no backpressure, consumer should keep sending). - 2nd
send(msg2)while msg1 still waits for ACK → queue length is now 2 → returnsfalse(backpressure: caller should pause).
The old < 16 threshold was a holdover that doesn't match Node — Node returns false immediately on the second queued message regardless of an arbitrary threshold. The new === 1 matches.
Test enablement
parallel/test-child-process-send-returns-boolean.js: enabled — directly exercises this assertion.parallel/test-child-process-recv-handle.js: added withignore: true("Uses internal/child_process kChannelHandle with readStop/readStart which is not exposed in Deno"). Reasonable scope-limit; that test exercises a different surface that this PR doesn't address.
CI
54 success, 12 pending, 0 fail at this HEAD (CI is rebuilding after the merge-main commit 559298c9). The 11 fails I noted on an earlier head must have been a stale CI state — the substantive shards haven't started yet. Will re-confirm once they land. Substance is APPROVE-quality once CI clears.
fibibot
left a comment
There was a problem hiding this comment.
LGTM — clearing the APPROVE-pending hold from my prior comment at this same HEAD. CI fully green now: 134 success, 2 skipping, 0 fail across all platforms × debug + release.
What I verified
The 1-line change matches Node's lib/internal/child_process.js semantics for send()'s return value:
- return handleQueue.length < 16;
+ return handleQueue.length === 1;- 1st
send(msg)while queue is empty → push makes queue length 1 → returnstrue(no backpressure, consumer should keep sending). - 2nd
send(msg2)while msg1 still waits for ACK → queue length is 2 → returnsfalse(backpressure: caller should pause).
The old < 16 threshold was a holdover; Node's actual behavior signals backpressure on the second-and-beyond queued message regardless.
Test enablement is right-sized:
parallel/test-child-process-send-returns-boolean.jsenabled — directly exercises the boolean return value contract.parallel/test-child-process-recv-handle.jsadded withignore: trueand a clean reason ("Usesinternal/child_processkChannelHandlewithreadStop/readStartwhich is not exposed in Deno") — separate surface, scope-limited correctly.
CI
134 success, 2 skipping, 0 fail. All 4 platforms × debug + release passed test node_compat, test unit_node, test specs, test integration.
…noland#33869) - Fix `child_process.send()` to return `false` when more than one message is queued waiting for a handle ACK, matching Node.js behavior - Previously used a threshold of 16 (`handleQueue.length < 16`), now uses `handleQueue.length === 1` to signal backpressure after the first queued message
Summary
child_process.send()to returnfalsewhen more than one message is queued waiting for a handle ACK, matching Node.js behaviorhandleQueue.length < 16), now useshandleQueue.length === 1to signal backpressure after the first queued messageTest plan
./x test-compat test-child-process-send-returns-boolean.jsnow passes