Repository navigation
Commit 09338b1
committed
fix(broker): close the listener before teardown and bound the idle timeout
Addresses both review findings on #680.
Stop accepting before the asynchronous app-server teardown. shutdown() closed
appClient first and only then closed the server, so the endpoint kept accepting
for the whole of that await. ensureBrokerSession's readiness probe could connect
during that window, judge a shutting-down broker "ready" and select it, then lose
the connection with no retry -- and an accepted socket could leave server.close()
waiting on an already-closed app server. server.close() now runs first, which
stops listening immediately and resolves once existing connections drain, so the
same reordering also covers the SIGTERM and SIGINT paths.
Reject idle timeouts above Node's timer range. setTimeout() overflows past
2^31-1 ms: it emits TimeoutOverflowWarning and then fires after 1ms. A user
asking for a 30-day timeout would therefore get an almost immediate shutdown --
the precise opposite of the request. Values above 2147483647 ms are now rejected
at startup, consistent with how non-numeric and negative values are handled.
Tests: an over-range timeout is rejected, exactly 2147483647 is accepted (the
guard is not off by one), and the SIGTERM case now asserts that the socket and
pidfile are cleaned up, covering the reordered shutdown on the signal path.1 parent e19c574 commit 09338b1
2 files changed
Lines changed: 44 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
38 | 47 | | |
39 | 48 | | |
40 | 49 | | |
| |||
166 | 175 | | |
167 | 176 | | |
168 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
169 | 183 | | |
170 | 184 | | |
171 | 185 | | |
| 186 | + | |
172 | 187 | | |
173 | | - | |
174 | 188 | | |
175 | 189 | | |
176 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
126 | 127 | | |
127 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
0 commit comments