Commit f8a28a7
committed
feat(devframe): add onServerError to observe post-bind server errors
startHttpAndWs's owned httpServer has no error listener once past the
bind window this PR's base fixes — the temporary listener is removed
the instant listen() succeeds. A later runtime error (e.g. a
transient EMFILE while accepting a connection) still crashes the
process, and StartedServer exposes no handle a caller could attach
their own listener to (unlike the shared-server path, where the
caller already owns the object).
Add an onServerError option instead of exposing the raw httpServer —
handing out the raw object would let a caller call close() on it
directly, bypassing the wrapper's close() and leaking the WS
transport exactly like the bug this PR's base fixes. The callback
fires for the bind-time error too (alongside the rejection), so it's
one place to observe every error the server ever emits, bind or
lifetime.
The lifetime-forwarding wire-up (httpServer.on('error', ...)) is a
one-line, logic-free pass-through of Node's own documented event and
isn't covered by a dedicated test: StartedServer deliberately doesn't
expose the raw server, so a test has no way to trigger a genuine
post-bind error without a test-only seam.
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent c770b07 commit f8a28a7
2 files changed
Lines changed: 38 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
118 | 136 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
112 | 122 | | |
113 | 123 | | |
114 | 124 | | |
| |||
256 | 266 | | |
257 | 267 | | |
258 | 268 | | |
259 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
260 | 273 | | |
261 | 274 | | |
262 | 275 | | |
| |||
273 | 286 | | |
274 | 287 | | |
275 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
276 | 295 | | |
277 | 296 | | |
278 | 297 | | |
| |||
0 commit comments