Commit 2e34a6f
committed
http2: settle pending write callbacks on stream destroy
When an HTTP/2 stream is destroyed while a write is still in flight,
nghttp2 may have already handed the data off to the socket and never
report the write's completion once the stream or session tears down. In
that case the callback that resolves the Writable write is never invoked,
so the Writable stays stuck and the event loop never drains, causing
test-http2-close-while-writing to time out on macOS.
In Http2Stream._destroy, settle any write that is still in flight 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-agent1 parent 6f41e41 commit 2e34a6f
2 files changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2721 | 2721 | | |
2722 | 2722 | | |
2723 | 2723 | | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
2724 | 2733 | | |
2725 | 2734 | | |
2726 | 2735 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
0 commit comments