diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-10-23 21:50:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-24 04:50:35 +0000 |
commit | 27df42f659ae7b77968d31363ade89addb516ea1 (patch) | |
tree | 4668ce4fe1b1bb32a4397b511dff46a818eab7a1 /ext/node/ops/ipc.rs | |
parent | 7c57105cc41cf16c5f48f85d85c7fd9bd3bb4d1f (diff) |
fix(ext/node): cancel pending ipc writes on channel close (#26504)
Fixes the issue described in
https://github.com/denoland/deno/issues/23882#issuecomment-2423316362.
The parent was starting to send a message right before the process would
exit, and the channel closed in the middle of the write. Unlike with
reads, we weren't cancelling the pending writes, which resulted in a
`Broken pipe` error surfacing to the user.
Diffstat (limited to 'ext/node/ops/ipc.rs')
-rw-r--r-- | ext/node/ops/ipc.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/node/ops/ipc.rs b/ext/node/ops/ipc.rs index 59b6fece1..c5e0f875d 100644 --- a/ext/node/ops/ipc.rs +++ b/ext/node/ops/ipc.rs @@ -216,10 +216,17 @@ mod impl_ { queue_ok.set_index(scope, 0, v); } Ok(async move { - stream.clone().write_msg_bytes(&serialized).await?; + let cancel = stream.cancel.clone(); + let result = stream + .clone() + .write_msg_bytes(&serialized) + .or_cancel(cancel) + .await; + // adjust count even on error stream .queued_bytes .fetch_sub(serialized.len(), std::sync::atomic::Ordering::Relaxed); + result??; Ok(()) }) } |