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

A request its client aborts settles as 499 and frees its handler #2236

Parked opened this
Closed without merging

A client abort now settles the request as 499 and frees its handler. The change is in src/http/server.ts, with a test in test/client-abort.test.ts. Abort handling: When request.signal aborts, the handler path settles.

Notes

stopped parked by the crew deploy 5d6dfeb

opened this

A client abort now settles the request as 499 and frees its handler. The change is in src/http/server.ts, with a test in test/client-abort.test.ts.

  • Abort handling:
    • When request.signal aborts, the handler path settles. A streaming body is cancelled, and the response is recorded as 499 in the request log and the metrics.
    • An aborted request is logged once, because logged() skips a request the abort already recorded.
    • Only a client abort ends a request, so git pushes aren't cut on purpose.
  • Security headers: the headers on every response are unchanged.
  • Test: a client aborts a slow or streaming route mid-response. The test checks that the server records 499 and that the in-flight counter returns to 0.
  • This push: the previous attempt (pull #2157) failed on "a site admin sees a degraded cause's sentence; anyone else sees nothing" in the terminal health screen. That area isn't touched by this change. I merged current main into the branch, and tsc --noEmit is clean.
  • Tests: test/client-abort.test.ts, test/tui-screens.test.ts, test/health.test.ts and test/sentinel.test.ts all pass (60 tests). I did not get a full bun test run to finish in the sandbox, so the forge's check does that. If the degraded-cause test fails again, I'd read it as unrelated to this change.

I didn't change anything outside the abort path.

To try it, run bun test test/client-abort.test.ts.

Closes #2150

commented

A client abort now settles the request as 499 and frees its handler. The change is in src/http/server.ts, with a test in test/client-abort.test.ts.

  • Abort handling:
    • When request.signal aborts, the handler path settles. A streaming body is cancelled, and the response is recorded as 499 in the request log and the metrics.
    • An aborted request is logged once, because logged() skips a request the abort already recorded.
    • Only a client abort ends a request, so git pushes aren't cut on purpose.
  • Security headers: the headers on every response are unchanged.
  • Test: a client aborts a slow or streaming route mid-response. The test checks that the server records 499 and that the in-flight counter returns to 0.
  • This push: the previous attempt (pull #2157) failed on "a site admin sees a degraded cause's sentence; anyone else sees nothing" in the terminal health screen. That area isn't touched by this change. I merged current main into the branch, and tsc --noEmit is clean.
  • Tests: test/client-abort.test.ts, test/tui-screens.test.ts, test/health.test.ts and test/sentinel.test.ts all pass (60 tests). I did not get a full bun test run to finish in the sandbox, so the forge's check does that. If the degraded-cause test fails again, I'd read it as unrelated to this change.

I didn't change anything outside the abort path.

To try it, run bun test test/client-abort.test.ts.

commented

Parked by the crew: the check failed ("the forge's health in the terminal > a site admin sees a degraded cause's sentence; anyone else sees nothing") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs