Repository navigation
feat(backend): replace WebSocket payment updates with SSE - #869
Open
Bayovictor wants to merge 1 commit into
Open
Bayovictor wants to merge 1 commit into
Bayovictor wants to merge 1 commit into
Conversation
…-code#730) Stream payment status updates over Server-Sent Events instead of Socket.io so one-way updates cost a single socket plus a map entry per client instead of a WebSocket upgrade, frame protocol and server-side ping bookkeeping. - add src/sse: client registry per payment topic, 25s keep-alive heartbeats, `retry:` hint, in-process emitPaymentUpdate, Redis publishPaymentUpdate and a closeSse() drain used by graceful shutdown (keeps the old wire channel and accepts the legacy paymentIntentId field) - add GET /payments/:paymentId/events emitting `connected`, a `snapshot` of the last known status (so EventSource reconnects converge immediately) and `payment-update` on every change; headers are flushed before async work so connect-timeout/compression cannot buffer or abort the stream - exempt SSE paths from the global token bucket and bound stream opens with a dedicated per-IP limiter instead - publish detected payments from horizonListener to Redis so the pipeline is live end to end (the old producer was imported but never called) - drop socket.io and src/websocket; nginx gets a no-buffer/no-timeout proxy location for the stream; .env.example, EVENT_SOURCING.md and README updated - add payment-dashboard/src/lib/paymentEvents.js wrapping EventSource (AC: reconnection handled natively by the EventSource API) and fix the broken lint-staged entry for dashboard files so staged files lint from repo root - cover the manager, route, Redis fan-out and shutdown in tests/sse.test.js plus a regression test that the listener publishes status updates
|
@Bayovictor is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Closes #730
What
Replaces the Socket.io/WebSocket realtime channel with plain-HTTP Server-Sent Events for one-way payment status updates: one socket plus one map entry per client instead of a WS upgrade, frame protocol and server-side ping bookkeeping.
stellar-payment-platform/src/sse/index.js— client registry keyed by payment topic, 25s keep-alive heartbeats,retry:hint, in-processemitPaymentUpdate, RedispublishPaymentUpdatefor cross-process fan-out, andcloseSse()drain used by graceful shutdown (keeps the legacy wire channel and accepts the oldpaymentIntentIdfield)GET /api/v1/payments/:paymentId/events(src/routes/v1/sseRoutes.js) — emitsconnected, asnapshotof the last known status (so anEventSourcereconnect converges immediately) andpayment-updateon every change; headers are flushed before any async work soconnect-timeout/compressioncannot buffer or abort the streamhorizonListener.jsnow publishes detected payments to Redis (the producer was imported but never called), so the pipeline is live end to endsocket.ioandsrc/websocket; nginx gets a no-buffer/no-timeout proxy location for the stream;.env.example,EVENT_SOURCING.mdandREADME.mdupdatedpayment-dashboard/src/lib/paymentEvents.jswrapsEventSource, so reconnection is handled natively by the browser (AC)lint-stagedentry so dashboard files lint from the repo rootAcceptance criteria
GET /api/v1/payments/:paymentId/eventsEventSourceAPI —payment-dashboard/src/lib/paymentEvents.jssrc/websocketremoved; per client cost is a single HTTP stream + map entryVerification
npx jest tests/sse.test.js tests/horizon-listener.test.js— 28 passed (manager, route, Redis fan-out, shutdown, listener regression)npx jest server.test.js— 67 passednpx eslinton the touched files — 0 errors (2 pre-existingno-unused-varswarnings onhorizonListener.js, present onmain)Related: #859