http2: settle pending write callbacks on destroy · nodejs/node@8921108 · GitHub
Skip to content

Commit 8921108

Browse files
mcollinaaduh95
authored andcommitted
http2: settle pending write callbacks on destroy
When a stream is destroyed while a write is still in flight, nghttp2 may have handed the data to the socket and never report the write completion once the stream or session tears down. That leaves the write callback unresolved, the Writable stuck, and the event loop never drains, which times out test-http2-close-while-writing on macOS. Settle the in-flight write in Http2Stream._destroy by invoking its callback with the destroy error and resetting writePending. A later native completion callback is then a no-op because writeCb is null and writePending is 0, so the settle is idempotent. Passing the error rather than null also drains any buffered writes. Fixes: #58252 Signed-off-by: Matteo Collina <hello@matteocollina.com> Assisted-by: pi-coding-agent PR-URL: #66016 Fixes: #58252 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
1 parent 1019f62 commit 8921108

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎lib/internal/http2/core.js‎

Lines changed: 9 additions & 0 deletions

‎test/parallel/test-http2-close-while-writing.js‎

Lines changed: 16 additions & 2 deletions

0 commit comments

Comments
 (0)