- Harden WebSocket forwarding behavior for close propagation, stream cleanup, and long-lived connections.
- Monitor per-stream backpressure under heavy load now that stream send/close is serialized; a full stream buffer can still stall one stream even though the close race is fixed.
- Monitor session-level stalls caused by bounded per-stream channels under sustained load; one blocked stream consumer can still delay tunnel traffic until protocol-level backpressure is added.
- Verify WebSocket handshake compatibility across stricter upstream servers, especially around forwarded upgrade headers and subprotocol negotiation.
- Add automated tests for protocol codecs, quota enforcement, route ownership, edge routing, HTTP forwarding, and WebSocket forwarding.
- Add integration/e2e tests covering
tunnel connect, public subdomain routing, multi-route sessions, HTTPS localhost targets, and WebSocket passthrough. - Add a DB-backed integration test that verifies route subdomains are reusable after soft delete / session expiry migrations are applied.
- Review and address full in-memory buffering of HTTP request/response bodies for larger payloads and long-lived traffic.
- Prevent large HTTP uploads/downloads from being fully buffered in memory in the edge/client tunnel path; switch to chunked streaming with limits and backpressure.
- Strengthen protocol envelope and frame-sequence validation; enforce control-vs-data rules plus required
session_id/route_idinvariants to avoid malformed-peer state corruption. - Extend protocol direction validation beyond the current client stream-frame checks so every frame type, stream state transition, and required identifier invariant is enforced consistently on both peers.
- Harden gateway session lifecycle error handling so repository/persistence failures send explicit control errors and trigger deterministic cleanup instead of silent disconnect paths.
- Add production-oriented load and soak tests for concurrent streams, large payloads, slow consumers, reconnect races, and session cleanup behavior.
- Review WebSocket upstream handshake behavior for production routing compatibility, including whether original public host/header context must be preserved for host-routed local WebSocket apps.
- Risk: host-routed local WebSocket upstreams may still misroute traffic because the public host/header context is not explicitly preserved during upstream WebSocket dialing.
- Add targeted tests for proxy header handling so hop-by-hop headers and
Connection-declared headers are never forwarded to local upstreams in production. - Add structured error classification for route/session operations so clients can distinguish not-found, quota, validation, and internal failures without relying on ambiguous fallback codes.
- Risk: HTTP request and response forwarding still buffers full bodies in memory, which can cause latency spikes or memory pressure under large or concurrent payloads before chunked streaming lands.
- Add explicit request/body size limits and abuse protections at the edge and tunnel layers before exposing the service to untrusted traffic.
- Risk: late-frame tombstones currently live for the lifetime of a connected session; very long-lived high-volume sessions may accumulate stream IDs until a bounded cleanup strategy is added.
- Add bounded tombstone cleanup for closed stream IDs so production sessions cannot grow unbounded stream bookkeeping under sustained traffic.
- Add production metrics and alerts for active streams, late-frame drops, reconnect outcomes, route/session cleanup failures, and per-session memory usage.
- Add end-to-end coverage for escaped-path forwarding and host-routed upstream behavior so public request semantics match the original edge request exactly.
- Add chunked HTTP request/response streaming with protocol-level flow control instead of full-body buffering before production traffic.
- Add hard per-stream and per-session memory caps so slow consumers or oversized payloads cannot exhaust the gateway, edge, or client process.
- Add stricter session and stream cleanup around disconnects and reconnect races so stale peers, timers, and streams are always retired deterministically.
- Risk: session and route creation in the SQL-backed control plane currently assumes every account already has an
account_quotasrow; missing quota bootstrap will surface as internal failures instead of a controlled account setup error. - Add an explicit account-provisioning invariant and startup/integration checks so every account has quota rows before any session or route operations are allowed.
- Add clearer error handling for missing or unreadable account quota state so clients receive a deterministic setup/internal error instead of a generic create/register failure.
- Add richer request and activity summaries to the agent API and CLI beyond counts and recent samples.
- Consider lightweight TUI scaffolding on top of the agent API.
- Risk: non-blocking stream send (select/default) now drops frames when a consumer is slow rather than blocking the read loop; add per-stream drop counters and surface them in metrics/logs so operators can detect and diagnose backpressure events before they cause silent data loss.
- Risk: the client-side
newStreamschannel (buffer 32) can block the WebSocket read loop if 32+ new streams arrive before being consumed by the handler goroutine; add bounded overflow handling or dynamic scaling before production burst traffic. - Risk:
ManagedSessioncontrol-message waiters silently discard non-matching control frames (heartbeat pongs, notices) while waiting for a route response; future protocol additions may require these frames to be routed elsewhere instead of dropped. - Add per-stream and per-session frame-drop metrics so operators can identify slow consumers and backpressure events in production.
- Add connection-level write timeouts and dead-peer detection beyond heartbeat interval so stale WebSocket connections are reaped promptly.
- Add rate limiting on route registration and session creation at the gateway layer (beyond quota enforcement) to prevent abuse from authenticated clients.
- Add TLS certificate validation and rotation strategy for production
wssconnections; the currentInsecureSkipVerify: trueon the gateway WebSocket acceptor must be removed. - Add graceful drain on shutdown so in-flight HTTP streams complete before the gateway and edge servers stop.
- Add request/response size limits at the edge proxy before
io.ReadAllto prevent a single large upload from exhausting process memory. - Add health-check and readiness probes for the edge server (currently only the gateway exposes
/healthz). - Add observability for reconnect manager state: active grace windows, token rotations, expiry events, and persistence failures.
- Add database connection pool monitoring and tuning; the current fixed pool (10 open / 10 idle) may need adjustment under production session and route churn.
- Add index on
sessions.account_idfor theCOUNT(*)query used in quota enforcement; without it, session quota checks do a sequential scan under high session counts. - Add index on
routes.account_idfor theCOUNT(*)query used in route quota enforcement. - Review soft-delete route cleanup strategy;
deleted_at IS NULLpartial indexes work but stale soft-deleted rows will accumulate without periodic pruning. - Add an explicit session-close frame exchange on client disconnect so the server can distinguish intentional shutdown from network failure before starting the grace window.
- Add active
session_closesending on graceful client/server shutdown (SIGTERM, user disconnect) so the newly-added handler is actually exercised; currently the code only handles receivingsession_closebut never sends it. - Risk:
handleWebSocketin the edge server spawns two proxy goroutines but only consumes one result from the error channel; the second goroutine runs unsupervised until deferred cleanup fires, which could delay error propagation or leave state inconsistent under rapid reconnects. - Add a cancellable context or explicit second-goroutine drain in
handleWebSocketso both proxy directions are deterministically stopped and their errors collected. - Risk: the
runOpenCLI command previously deadlocked becauseStart()was not called beforeRegisterRoute(); any future code path that calls control-plane methods onManagedSessionbeforeStart()will hit the same hang — add a guard or document the required call order. - Add integration test coverage for the
tunnel openCLI path to catch regressions in theStart → RegisterRoute → Runordering. - Risk:
session_closeis now parsed but has no protocol-level tests validating encode/decode round-trips, server handling, or client-side teardown behavior; add unit and integration tests before relying on it for graceful shutdown. - Add per-connection write-queue depth monitoring on the tunnel WebSocket so slow or stalled clients are detected and reaped before they back-pressure the edge proxy.
- Add explicit max request/response body size enforcement at the edge (
http.MaxBytesReader) and at the client proxy layer beforeio.ReadAllcalls to prevent a single oversized payload from exhausting process memory. - Add structured logging context (request ID, stream ID, route ID) to all edge and client proxy error paths so production issues can be traced end-to-end without correlating timestamps.
- Add a bounded retry or circuit-breaker for
session.Touchfailures in the gateway read loop; currently a single Touch error silently disconnects the client. - Risk: the
ManagedSession.readLoopsends to the unbufferederrCh(cap 1); ifRun()is slow to consume, a second rapid error could block the read loop goroutine indefinitely. - Add production smoke tests that exercise the full tunnel path (connect → register → HTTP request → WebSocket echo → route delete → disconnect) against a real Postgres backend as part of CI.
- Add client-side reconnect logic that automatically re-establishes the session within the grace window when the WebSocket connection drops unexpectedly, rather than requiring the caller to manually invoke
Resume. - Review and tighten the
InsecureSkipVerify: trueon the gateway WebSocket acceptor (ws.AcceptOptions) — this disables origin checking and must be replaced with an explicit origin allowlist before production exposure. - Add Sentry error tracking integration for both tunneld (server) and tunnel (client) binaries so panics, unhandled errors, and protocol violations are captured with full stack traces and session/route context for production debugging.
- Wire Sentry breadcrumbs for key events: tunnel connect, route register/delete, session resume, reconnect attempts, edge request dispatch, and upstream dial failures so errors can be replayed with a full operational timeline.
- Add Postgres event logging integration: emit structured audit events for session create/delete/resume, route register/delete, quota checks (hits and denials), auth successes and failures, and control-plane errors to a dedicated
audit_eventstable or a log-fdw table for SIEM ingestion. - Ensure audit events are written asynchronously (non-blocking) so a slow or unavailable database does not back-pressure the tunnel gateway or edge proxy request paths.
- Add correlation IDs (request ID, stream ID, route ID, session ID) to Sentry events and audit log entries so a single user-reported issue can be traced across Sentry errors, Postgres audit logs, and structured app logs without manual timestamp correlation.
- Add Sentry sampling configuration so high-traffic periods do not overwhelm the error tracking quota; sample tunnel ProtocolViolation and stream_error events at higher rates than routine HTTP 404s.
- Risk: Sentry client initialization with a nil DSN (or when the Sentry integration is not configured) must not panic or block startup; use a no-op fallback so tunneld starts without Sentry in dev or airgap environments.
- Add Postgres connection pool metrics (open, idle, in-use, wait time) to the observability layer alongside existing reconnect manager metrics so database exhaustion can be detected before it causes cascading tunnel failures.