Ciro Spaciari
0ad562d3bd
fix(http2) Fix SSLWrapper and allow injecting connections in Http2SecureServer ( #26539 )
...
### What does this PR do?
Enables the `net.Server → Http2SecureServer` connection upgrade pattern
used by libraries like
[http2-wrapper](https://github.com/szmarczak/http2-wrapper ),
[crawlee](https://github.com/apify/crawlee ), and custom HTTP/2 proxy
servers. This pattern works by accepting raw TCP connections on a
`net.Server` and forwarding them to an `Http2SecureServer` via
`h2Server.emit('connection', rawSocket)`.
#### Bug fixes
**SSLWrapper use-after-free (Zig)**
Two use-after-free bugs in `ssl_wrapper.zig` are fixed:
1. **`flush()` stale pointer** — `flush()` captured the `ssl` pointer
*before* calling `handleTraffic()`, which can trigger a close callback
that frees the SSL object via `deinit`. The pointer was then used after
being freed. Fix: read `this.ssl` *after* `handleTraffic()` returns.
2. **`handleReading()` null dereference** — `handleReading()` called
`triggerCloseCallback()` after `triggerDataCallback()` without checking
whether the data callback had already closed the connection. This led to
a null function pointer dereference. Fix: check `this.ssl == null ||
this.flags.closed_notified` before calling the close callback.
### How did you verify your code works?
- Added **13 in-process tests** (`node-http2-upgrade.test.mts`) covering
the `net.Server → Http2SecureServer` upgrade path:
- GET/POST requests through upgraded connections
- Sequential requests sharing a single H2 session
- `session` event emission
- Concurrent clients with independent sessions
- Socket close ordering (rawSocket first vs session first) — no crash
- ALPN protocol negotiation (`h2`)
- Varied status codes (200, 302, 404)
- Client disconnect mid-response (stream destroyed early)
- Three independent clients producing three distinct sessions
- Tests use `node:test` + `node:assert` and **pass in both Bun and
Node.js**
- Ported `test-http2-socket-close.js` from the Node.js test suite,
verifying no segfault when the raw socket is destroyed before the H2
session is closed
---------
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-02-04 19:23:29 -08:00
..
2026-01-14 13:07:38 -08:00
2025-05-12 13:43:54 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-12-23 22:24:18 -08:00
2025-07-25 19:14:22 -07:00
2025-06-30 14:52:50 -07:00
2025-07-25 19:14:22 -07:00
2025-06-30 14:52:50 -07:00
2025-07-25 19:14:22 -07:00
2025-07-25 19:14:22 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-07-25 19:14:22 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-20 11:53:36 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-08-20 16:02:10 -07:00
2025-11-07 05:28:33 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-09-04 14:59:35 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-07-25 19:14:22 -07:00
2025-07-25 19:14:22 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-12-23 22:24:18 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-16 23:17:35 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-10-20 19:39:10 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-06-30 14:52:50 -07:00
2025-09-13 01:00:57 -07:00
2025-12-14 22:49:51 -08:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-07-02 15:04:39 -07:00
2025-07-02 15:04:39 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-11-20 17:14:37 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-09-09 00:45:22 -07:00
2025-09-09 00:45:09 -07:00
2025-07-29 17:20:16 -07:00
2025-06-30 14:52:50 -07:00
2025-06-05 17:34:30 -07:00
2025-06-05 17:34:30 -07:00
2025-05-13 16:47:42 -07:00
2026-01-22 14:35:18 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 19:27:41 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-13 16:47:42 -07:00
2025-05-13 16:47:42 -07:00
2025-05-13 16:47:42 -07:00
2025-05-13 16:47:42 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-05 17:34:30 -07:00
2025-07-29 17:20:16 -07:00
2025-05-13 16:47:42 -07:00
2025-06-30 14:52:50 -07:00
2025-05-13 16:47:42 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-05 17:34:30 -07:00
2025-06-30 14:52:50 -07:00
2025-06-05 17:34:30 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-14 18:56:55 -07:00
2025-05-28 19:26:20 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2026-01-22 14:35:18 -08:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-13 16:47:42 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2026-02-04 19:23:29 -08:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2026-01-22 14:35:18 -08:00
2025-06-30 14:52:50 -07:00
2025-05-28 19:27:12 -07:00
2026-01-22 14:35:18 -08:00
2025-07-29 17:20:16 -07:00
2025-05-12 13:44:10 -07:00
2025-11-04 11:56:33 -08:00
2025-06-30 14:52:50 -07:00
2025-11-04 11:56:33 -08:00
2025-11-04 11:56:33 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 20:03:32 -07:00
2025-09-04 15:18:31 -07:00
2025-10-31 23:24:32 -07:00
2025-05-28 19:28:02 -07:00
2025-06-30 14:52:50 -07:00
2025-11-04 11:56:33 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-11-04 11:56:33 -08:00
2025-11-04 11:56:33 -08:00
2025-05-14 22:15:33 -07:00
2025-11-04 11:56:33 -08:00
2025-11-04 11:56:33 -08:00
2025-05-31 16:21:08 -07:00
2025-05-31 16:21:08 -07:00
2025-06-30 14:52:50 -07:00
2025-09-04 15:18:31 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-11-04 11:56:33 -08:00
2025-07-24 13:46:50 -07:00
2025-08-27 19:35:30 -07:00
2025-05-14 22:15:33 -07:00
2025-05-14 22:15:33 -07:00
2025-05-14 22:15:33 -07:00
2025-11-04 11:56:33 -08:00
2025-11-04 11:56:33 -08:00
2025-11-04 11:56:33 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 00:31:44 -07:00
2025-05-28 17:04:37 -07:00
2025-06-24 17:48:06 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 22:21:28 -07:00
2025-05-28 22:21:28 -07:00
2025-06-27 14:42:25 -07:00
2025-05-28 17:04:37 -07:00
2025-06-24 02:56:50 -07:00
2025-06-24 01:02:38 -07:00
2025-05-28 17:04:37 -07:00
2025-06-24 22:46:56 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-24 02:56:40 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 22:27:52 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-27 14:42:52 -07:00
2025-05-28 21:38:52 -07:00
2025-05-29 13:55:25 -07:00
2025-06-03 22:50:08 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-05-29 11:31:26 -07:00
2025-05-28 17:04:37 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-14 18:50:26 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-07-03 16:26:32 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 18:04:31 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-13 19:05:05 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 19:26:44 -07:00
2025-09-04 22:31:11 -07:00
2025-06-30 14:52:50 -07:00
2025-06-02 23:03:47 -07:00
2025-10-29 15:55:41 -07:00
2025-05-29 22:53:28 -07:00
2025-05-15 21:38:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-12-05 11:19:47 -08:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-24 22:39:20 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-04 16:44:15 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-29 22:53:28 -07:00
2025-05-29 22:53:28 -07:00
2025-05-28 17:04:37 -07:00
2025-06-30 14:52:50 -07:00
2025-06-13 17:30:04 -07:00
2025-06-13 17:30:04 -07:00
2025-06-13 17:30:04 -07:00
2025-06-13 17:30:04 -07:00
2025-06-13 17:30:04 -07:00
2025-06-13 17:30:04 -07:00
2025-06-13 17:30:04 -07:00
2025-09-24 21:55:57 -07:00
2025-09-24 21:55:57 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-05-28 17:04:37 -07:00
2025-05-26 13:13:59 -07:00
2025-06-30 14:52:50 -07:00
2025-05-29 22:53:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-09-04 22:31:11 -07:00
2025-06-30 14:52:50 -07:00
2025-05-23 22:59:58 -07:00
2025-07-07 19:29:53 -07:00
2025-06-04 19:41:26 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-04 19:41:26 -07:00
2025-05-23 22:59:58 -07:00
2025-07-07 19:29:53 -07:00
2025-07-07 19:29:53 -07:00
2025-05-23 22:59:58 -07:00
2025-06-04 19:41:26 -07:00
2025-05-23 22:59:58 -07:00
2025-06-04 19:41:26 -07:00
2025-07-07 19:29:53 -07:00
2025-06-04 19:41:26 -07:00
2025-06-30 14:52:50 -07:00
2025-07-07 19:29:53 -07:00
2025-06-30 14:52:50 -07:00
2025-06-04 19:41:26 -07:00
2025-05-23 22:59:58 -07:00
2025-06-30 14:52:50 -07:00
2025-05-23 22:59:58 -07:00
2025-12-23 22:24:18 -08:00
2025-05-23 22:59:58 -07:00
2025-05-23 22:59:58 -07:00
2025-05-29 22:53:28 -07:00
2025-07-25 19:14:22 -07:00
2025-07-25 19:14:22 -07:00
2025-06-30 14:52:50 -07:00
2025-05-16 22:30:58 -07:00
2025-06-30 14:52:50 -07:00
2025-11-20 17:14:37 -08:00
2025-05-23 16:50:13 -07:00
2025-05-14 18:56:14 -07:00
2025-05-14 18:57:29 -07:00
2025-05-14 18:56:14 -07:00
2025-06-02 23:03:47 -07:00
2025-05-12 14:10:18 -07:00
2025-06-30 14:52:50 -07:00
2025-07-25 19:13:48 -07:00
2025-06-30 14:52:50 -07:00
2025-06-12 14:20:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-12 14:20:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-30 14:52:50 -07:00
2025-06-12 14:20:28 -07:00
2025-06-30 14:52:50 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00
2025-06-12 14:20:28 -07:00