Repository navigation
fix: retry unacked events over an open WebSocket - #83
Merged
Merged
Conversation
A connected node only received events when they first arrived or when it authenticated. If a delivery failed (the node didn't ack, e.g. its local webhook returned 404), the event sat in `leased` until the node reconnected. Before the keepalive (#81) the ~45s reconnect cycle masked this; with stable connections an unacked event could wait indefinitely. Re-send pending and lease-expired events on every 30s keepalive tick, using the existing pushPendingEventsForNode (which re-leases, so nothing is sent twice inside a lease window). Nothing is re-sent to a node being terminated.
Strix Security ReviewNo security issues found. Review summaryThe PR adds retry of pending/lease-expired events on each of a node's WebSocket keepalive ticks, reusing the existing pushPendingEvents path rather than introducing new logic. The changed connection handler was reviewed together with the wired dependencies in the server entrypoint. All database interactions remain parameterized and scoped to the authenticated node, no authorization or input-validation controls were removed, the unresponsive-node termination path correctly skips re-sending, and retries are bounded by an attempt count. No security vulnerabilities were identified in the changed code. Updated for Reviewed by Strix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Found during the Hermes plugin rollout. A connected node only gets an event when it first arrives (ingress push) or when the node authenticates (
pushPendingEventsForNode). If the node doesn't ack (in the rollout, the local Hermes route returned 404), the event staysleasedand is never retried while the connection stays open. Two test events sat stuck for 4+ minutes after their 60s lease expired.Before #81 the relay reconnected every ~45s, which quietly re-sent stuck events on each new connection. The keepalive made connections stable, so the gap is now real.
Change
app/lib/ws/node-socket.ts: on each 30s keepalive tick, callpushPendingEvents(ws, nodeId), the same function used at auth, which selectspendingplus lease-expiredleasedevents and re-leases them. So nothing is sent twice inside a lease window. A tick that terminates an unresponsive node doesn't re-send.Tests (written first)
yarn vitest run: 245/245. Lint clean, no type errors outside tests.