You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(http): wake runtime after direct serve dispatch (#34387)
Fixes#34369.
## Root cause
`Deno.serve` request dispatch now calls the JS request handler directly
from a standalone hyper task. That path performs a V8 microtask
checkpoint after invoking the callback, but it does not otherwise
guarantee that the full `JsRuntime` event loop is polled again.
If the handler reaches an async boundary backed by `node:net` /
uv-compatible I/O, the TCP handle can be marked ready inside the
uv-compat layer, but the outer runtime task still needs to be woken so
the uv I/O phase runs. Previously the mpsc/op-driven request path
provided that scheduling edge implicitly.
This change stores the runtime waker in `ServerCallback` and wakes it
after direct JS dispatch, restoring one full event-loop pass after
request-handler invocation.
## Changes
- Thread the runtime `OpState` waker into `ServerCallback`.
- Wake the runtime after the post-dispatch microtask checkpoint.
- Add a regression test covering `Deno.serve` awaiting `node:net` I/O
from inside the request handler.
## Validation
- `cargo build --profile release-lite --bin deno`
- `./target/release-lite/deno run
--allow-net=127.0.0.1:12477,127.0.0.1:12478
tests/specs/serve/node_net_wake/main.ts`
I also checked the regression against an unfixed release-lite binary: it
timed out after 5s. The fixed binary returned `ok` immediately.
## Performance
Hello-world `Deno.serve`, release-lite builds, `oha -z 15s -c 100`,
alternating baseline/fixed samples:
| Build | Avg req/s | Avg p50 | Avg p99 |
| --- | ---: | ---: | ---: |
| baseline | 135,073 | 0.707 ms | 0.897 ms |
| fixed | 134,452 | 0.709 ms | 0.903 ms |
Throughput delta: -0.46%, within local run noise.
0 commit comments