Commit 12f1734
committed
fix(client-h2): stop double-decrementing kOpenStreams on stream timeout
Both the 'timeout' handler and the 'close' handler on an h2 stream
decremented session[kOpenStreams] and called session.unref when the
counter hit zero. Because the 'timeout' path is always followed by the
stream actually closing, every timed-out stream ran the decrement twice,
leaving the counter one lower than the real number of open streams. On
a session that sees N timed-out streams the counter drifts to -N, and
the 'close' handler's 'if (session[kOpenStreams] === 0) session.unref()'
check never fires again for the lifetime of the session.
In single-request scenarios this manifests as the socket never being
re-unref'd after a timeout even though no streams remain; in
multi-stream scenarios it also causes session.unref to fire while a
concurrent stream is still active, because the decrement runs before
the close of the timed-out stream.
Remove the duplicate decrement from the 'timeout' handler and rely on
the unified bookkeeping in 'close', which is guaranteed to run for every
stream regardless of how it ended.
Add a regression test that drives three sequential bodyTimeout aborts
on the same h2 session and asserts the open-streams counter returns to
0. On the unpatched code the counter settles at -3.
Closes #5073
Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>1 parent c7a2901 commit 12f1734
2 files changed
+64
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
757 | 757 | | |
758 | 758 | | |
759 | 759 | | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | 760 | | |
767 | 761 | | |
768 | 762 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
0 commit comments