Public: anyone can read this; the crew can change it.

Bun 1.4.4 leaves two tests red on main: the keep-alive handover and a websocket handshake the app refuses #12728

opened this

Merged 20d 11h ago, live in production

Both tests are green on Bun 1.4.4. The keep-alive test was reproduced red and now passes. The websocket test never failed here, so its fix is a precaution.

Notes

opened this

Both tests are green on Bun 1.4.4. The keep-alive test was reproduced red and now passes. The websocket test never failed here, so its fix is a precaution. I ran those two test files, tsc --noEmit and bun scripts/gate.ts (clean); I did not run the full suite.

Keep-alive handover (test/release-handover-keepalive.test.ts): Bun 1.4.4 closes an idle kept-alive connection itself when stop(false) runs. So the old forge has nothing left to answer on a warmed connection. That is why the next fetch got 404 from the release.

  • The test now warms one raw TCP connection (openRaw, a small HTTP/1.1 client over Bun.connect) so reuse is provable.
  • It then asserts the handover closes that connection, and that fresh connections reach the release (404).
  • The connection: close wrapper in src/http/server.ts stays. It still covers a connection that is busy when the port is handed over, but no test exercises that case now.

Websocket refusal (connectUpstream in src/apps/proxy.ts): test/apps-ws.test.ts passed here, alone and with the whole file. I couldn't reproduce the 502 "app stopped answering" page.

  • My guess is a race: the close event arriving before the error event that says the app refused the handshake.
  • The close handler now resolves a tick later (setTimeout(…, 0)), so the refusal flag is set before it is read.
  • This is unconfirmed. If the test still fails in the forge's check, the cause is elsewhere.

I didn't touch the tests tracked in #12716 and #12618.

To try it: bun test test/release-handover-keepalive.test.ts test/apps-ws.test.ts.

🤖 Generated with Claude Code

Closes #12727

2 earlier comments
commented

Both tests are green on Bun 1.4.4. The keep-alive test was reproduced red and now passes. The websocket test never failed here, so its fix is a precaution. I ran those two test files, tsc --noEmit and bun scripts/gate.ts (clean); I did not run the full suite.

Keep-alive handover (test/release-handover-keepalive.test.ts): Bun 1.4.4 closes an idle kept-alive connection itself when stop(false) runs. So the old forge has nothing left to answer on a warmed connection. That is why the next fetch got 404 from the release.

  • The test now warms one raw TCP connection (openRaw, a small HTTP/1.1 client over Bun.connect) so reuse is provable.
  • It then asserts the handover closes that connection, and that fresh connections reach the release (404).
  • The connection: close wrapper in src/http/server.ts stays. It still covers a connection that is busy when the port is handed over, but no test exercises that case now.

Websocket refusal (connectUpstream in src/apps/proxy.ts): test/apps-ws.test.ts passed here, alone and with the whole file. I couldn't reproduce the 502 "app stopped answering" page.

  • My guess is a race: the close event arriving before the error event that says the app refused the handshake.
  • The close handler now resolves a tick later (setTimeout(…, 0)), so the refusal flag is set before it is read.
  • This is unconfirmed. If the test still fails in the forge's check, the cause is elsewhere.

I didn't touch the tests tracked in #12716 and #12618.

To try it: bun test test/release-handover-keepalive.test.ts test/apps-ws.test.ts.

🤖 Generated with Claude Code

commented

The only red this pull caused was timers-named, and that is fixed and pushed. I ran test/timers-named.test.ts and test/release-handover-keepalive.test.ts locally (both pass) and bun scripts/gate.ts (clean). I did not run tsc or the full suite this round.

The cause was the setTimeout I added in connectUpstream (src/apps/proxy.ts), which makes the refused-handshake verdict wait one tick after the close event. The test requires every server-side timer to run inside during or to be on its allowlist. I added a one-line entry in test/timers-named.test.ts naming that timer, because the callback just resolves a promise and has no work to wrap in during.

An earlier push carried the // real-timer: comment on the raw-socket wait in test/release-handover-keepalive.test.ts. The gate passes now.

The other red tests in the check log — check-install, apps-open-host and ask-to-reach — the check log says are red on main too (tracked in #12716 and #12618). Its list of failing tests also names the prefillInstallCache test, the crew-concurrency test and a few more; I did not look at those, so I can't say whether any of them touch this pull.

commented

This pull now fixes only the keep-alive handover test, and a new test guards the busy-connection case. I ran the two affected test files and bun x tsc --noEmit, and both are clean. I did not run scripts/gate.ts, scripts/fast.ts or the full suite; the forge's check runs the suite on this push.

What changed

  • Websocket timer dropped. I reverted the src/apps/proxy.ts change and the timers-named allowlist entry, as juniper asked. The deferred verdict was never backed by a failing test. The refused-handshake websocket test belongs in its own issue, once someone can reproduce the close-before-error order.
  • Busy handover test added. In test/release-handover-keepalive.test.ts, a new test sends a POST to /api/v1/users with only part of its body, so the request is in flight inside the handler. It runs stopAccepting, then sends the rest of the body. It asserts the answer carries connection: close. With the connection: close wrapper in src/http/server.ts removed, this test fails with Received: undefined.
  • Raw-socket helper extended. The helper gained write, send and answer so the split request can use it.

Not done: I did not touch the idle-connection test or the real-timer comment, which juniper found fine.

To try: bun test test/release-handover-keepalive.test.ts.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs