Skip to content

Harden controller connection and request lifecycles - #7

Draft
rayshobby wants to merge 3 commits into
masterfrom
fix/connection-lifecycle-hardening
Draft

rayshobby wants to merge 3 commits into
masterfrom
fix/connection-lifecycle-hardening

Conversation

@rayshobby

@rayshobby rayshobby commented Oct 25, 2026 •

Copy link
Copy Markdown

Requests with bodies could lose their pending response before the controller replied. Concurrent authentication and late socket cleanup could also overwrite or remove another connection's ownership. This change ties registration and pending requests to individual sessions while retaining healthy existing owners.

  • Await authentication before registration and protocol handling, with a ten-second deadline and a final socket/ownership check.
  • Make cleanup idempotent and session-owned; settle each forwarded request once across replies, browser departure, send failures, timeout, and controller loss.
  • Reject with WebSocket close codes 1008/1011 and a five-second termination fallback.
  • Add a validated 60-second request deadline without automatic replay, including GET commands. Allocate sequential four-hex request IDs while skipping pending IDs, with bounded capacity handling.
  • Add token-safe lifecycle and endpoint diagnostics, distinguish backend authentication failures, and preserve useful startup configuration errors. HTTP completion logs retain the controller status even when replies bypass Express header handling.
  • Pin the Docker base to Node 22.18.0 Alpine by immutable digest and gate image builds on regression tests and type checks.

Validation: 40 tests pass on Node 22.18.0 and 24.19.0 using isolated loopback servers and stubbed authentication. Type checks and application/image builds pass. Coverage includes GET, empty POST, body POST, concurrent and fragmented responses, authentication races and deadlines, late cleanup, abandoned requests, heartbeat expiry, close fallback, ID wrap/capacity, and log privacy. A real response delayed 31 seconds completes under the default deadline.

The unchanged four-hex wire format retains a documented same-session ID-reuse limitation after counter wrap. Actual legacy-device retry pacing and firmware compatibility still require staging validation. This PR remains a draft pending that validation; it does not deploy services or change firmware.

Restore safe configuration errors, retain recognized endpoint names, and pin the Docker runtime to Node 22.18.0 by digest. Add regressions for authentication timeout, late results, startup failures and endpoint privacy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant