Skip to content

Adopt real-socket adapter cancellation and timeout conformance guard #23

Description

@smiggleworth

Summary

Adopt the shared @askrjs/server/testing adapter conformance runner against the real @askrjs/node listener, so response cancellation and incomplete-request timeouts remain executable cross-package guarantees.

Dependency and implementation contract

Depends on askrjs/askr-server#20 and its released @askrjs/server/testing entry point.

Use real loopback sockets, not a mocked ServerResponse:

  • cancellation exercise: serve the runner's infinite response, read at least one chunk over TCP, destroy the client, and wait for the runner to observe ReadableStream.cancel();
  • timeout exercise: listen with explicit finite requestTimeout/headersTimeout, send an incomplete chunked request over a raw socket, and resolve only when Node closes the connection;
  • every exercise owns deterministic cleanup and alternate ephemeral ports; no default-port assumptions;
  • retain the existing direct unit coverage for writeNodeResponse() and timeout option validation.

The red transport run proved a real timeout gap: assigning server.requestTimeout and server.headersTimeout only after createServer() leaves Node's incomplete-connection checker at its 30-second construction default, so authored 100 ms values did not terminate the stalled body within two seconds. Initialize request/header/keep-alive timeouts and connectionsCheckingInterval during construction in both listen() and serve(). Choose a positive check interval no slower than the smallest configured request/header timeout, capped at one second, then restore the exact authored public property values so existing mixed timeout configurations remain compatible.

Acceptance criteria

  • Verify the issue author is smiggleworth.
  • Upgrade to the released server version that exports @askrjs/server/testing.
  • Run the shared adapter conformance runner through the real Node listener.
  • A real client abort cancels the infinite Web response body within the conformance deadline.
  • An incomplete raw HTTP request is terminated by explicit finite adapter timeouts within the conformance deadline.
  • listen() and serve() initialize Node timeout/checking machinery during server construction while retaining the exact authored timeout property values.
  • Both exercises honor cleanup signals and close sockets/servers on success and failure.
  • Existing adapter response, timeout-option, WebSocket, and package tests remain green.
  • Guardrail (prevent this class of bug): Keep the shared real-socket conformance test in the normal unit/CI suite so future response-loop or timeout wiring changes cannot bypass it.
  • Full unit, type, build, package-artifact, audit, and exact-head hosted CI gates pass.

Definition of done

  • Every criterion above is checked with evidence before squash merge, and version 0.0.12 is release-ready at the exact head.

Severity

Medium — response cancellation was correct, but the real-transport guard proved authored timeout values were not enforced promptly because the checker was initialized too late.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions