Repository navigation
fix: connect analytics streams, clear rpc timers, and cover notification delivery - #1808
Open
nemeregiftbrown-byte wants to merge 3 commits into
Open
nemeregiftbrown-byte wants to merge 3 commits into
nemeregiftbrown-byte wants to merge 3 commits into
Conversation
…ion delivery (LabsCrypt#1709, LabsCrypt#1710, LabsCrypt#1711) - LabsCrypt#1709: Connect analytics explorer to documented backend stream endpoint. Update useStreams to query the configured backend API URL and documented stream-list endpoint (/v1/streams) by default. Normalize actual REST streamId instead of database UUID, map startTime and endTime without zero dates, derive status across active/paused/completed/cancelled states, and resolve token metadata with standard 7 decimals instead of silently defaulting to 18. Add unit and integration tests mounting AnalyticsPage against representative backend responses. - LabsCrypt#1710: Clear RPC timeout timers on settled operations and probes. Store timeout handles in execute and probeAll and clear them in finally blocks upon settlement or early failure, preventing lingering timers and late AbortSignal triggers on already completed operations while preserving timeouts for hung requests. Add fake-timer unit tests. - LabsCrypt#1711: Cover notification delivery failures and expired subscriptions. Add backend test suite for NotificationService verifying failure isolation across WebPush, Telegram, and Discord transports, removal of expired endpoints on HTTP 404/410, retention on transient failures, and suppression of push delivery when VAPID is unconfigured.
…timestamp in stream-analytics test
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.
Overview
This pull request resolves three issues across the frontend analytics explorer, backend RPC connection pool, and backend notification service, and resolves the CI test failures on GitHub Actions:
/v1/streams) viaNEXT_PUBLIC_API_URLby default. Normalizes actual REST stream responses by preferring on-chainstreamIdover database UUIDs, mappingstartTimeandendTimeto timestamps without zero dates, properly mapping status across active, paused, completed, and cancelled states, and resolving token decimals to the standard 7-decimal scale instead of silently substituting 18 decimals.finallyblocks on settled RPC operations inexecuteand settled health probes inprobeAll. This prevents lingering timers from holding closures in the Node event loop and prevents lateAbortSignalabort triggers after an operation has already succeeded or failed early, while preserving timeouts and aborts for genuinely hung requests.NotificationService. Exercises failure isolation across WebPush, Telegram, and Discord transports (verifying a rejected channel does not block delivery to other configured channels), verifies deletion of expired endpoints on HTTP 404 and 410, verifies retention of subscriptions on transient errors, and verifies push delivery suppression when VAPID keys are absent.backend/tests/rpc-pool.test.tsduring fake timer advancement and eliminates static timestamp expiration infrontend/src/__tests__/stream-analytics.test.tsxby using dynamic current timestamps.Detailed Changes
Frontend Analytics Stream Normalization (#1709)
useStreamsto defaultendpointtogetDefaultStreamsEndpoint(), which resolves againstgetApiBaseUrl()(respectingNEXT_PUBLIC_API_URLor falling back tohttp://localhost:3001/v1/streams). This replaces the hardcoded frontend origin/api/streamsroute where no rewrite or handler existed.normalizeStreamnow prioritizesrecord.streamId/record.stream_idover the database UUIDrecord.id, ensuring UI table rows and filters display the user-facing Soroban on-chain stream IDs.startTimeandendTimeare correctly mapped tostartTimestampandendTimestamp. WhencreatedAtis omitted, it derives safely fromstartTimestampinstead of generating current timestamps or zero dates.isActive,isPaused, andevents) intoactive,paused,completed, andcancelled(whenCANCELLEDevent is present), while continuing to support explicit status strings.TOKEN_ADDRESSES(USDC, XLM, EURC) and defaults to 7 decimals (the Stellar standard scale) rather than silently substituting 18 decimals when decimals are omitted.remainingBalanceis derived fromdepositedAmount - withdrawnAmountwhen not explicitly present in the REST payload.export-accounting.tsandstream-metrics.tsfallback decimals from 18 togetDefaultTokenDecimals(symbol)(7 decimals).AnalyticsPageagainst representative active, paused, cancelled, and completed records.Backend RPC Pool Timeout Cleanup (#1710)
timeoutHandlefromsetTimeoutand wrapped operation execution intry ... finallyto ensureclearTimeout(timeoutHandle)is invoked upon settlement (success or early failure).controller.abort()is never invoked after success, avoiding false abort signals.finallyfor all endpoints inprobeAll.timeoutMs, fire theAbortSignal, and proceed with endpoint failover.backend/tests/rpc-pool.test.tsutilizing Vitest fake timers (vi.useFakeTimers) to verify timer cleanup, absence of late aborts, early failure failover, genuine timeout aborts, and health probe timeout cleanup.Backend Notification Service Delivery & Expired Subscription Tests (#1711)
webpush, Telegramfetch, and Discordfetchtransports. Verified that a rejected push notification does not prevent Telegram or Discord deliveries, a rejected Telegram call does not prevent push or Discord deliveries, and a rejected Discord call does not prevent push or Telegram deliveries.prisma.pushSubscription.deleteMany({ where: { endpoint } }).VAPID_PUBLIC_KEYorVAPID_PRIVATE_KEYprevents push delivery attempts while permitting Telegram and Discord channels.subscribeWebPush,unsubscribeWebPush,generateLinkCode,linkTelegram, andsetDiscordWebhook.CI Bugfixes & Stability
backend/tests/rpc-pool.test.ts, when testingrejects with timeout when all endpoints genuinely hang,vi.advanceTimersByTimeAsync(2000)was triggered before attaching the rejection assertion on the returned promise. Node.js emitted an unhandled promise rejection error caught by Vitest. Fixed by attaching the expectation assertionconst assertion = expect(resultPromise).rejects.toThrow(...)before advancing fake timers, then awaiting the assertion.frontend/src/__tests__/stream-analytics.test.tsx, mock stream fixtures used a fixed January 2025 date forNOW_SECONDS. WhenAnalyticsPagerendered in 2026,Date.now()determined the streams had expired in the past (secondsRemaining === 0), yielding0active positions instead of1. Updated the fixture to computenowSeconds = Math.floor(Date.now() / 1000)dynamically.Verification
npm run lint --workspace=frontend: passed (0 errors, 17 warnings).npm test --workspace=frontend: 78 test files passed (728 total tests passed, includingstream-analytics.test.tsx).npm run build --workspace=frontend: Next.js Turbopack build succeeded with static page generation.bash frontend/scripts/check-bundle-size.sh: passed (568,989 bytes within 614,400 byte budget).npm run build --workspace=backend:tsccompilation succeeded with exit code 0.npm run codegen:openapi&npm run codegen:api-types: OpenAPI spec and TypeScript client drift check passed with clean diff.npx vitest run tests/rpc-pool.test.ts: all 8 tests passed with 0 unhandled rejections.npx vitest run tests/notification.service.test.ts: all 17 tests passed.Issue Links
Closes #1709
Closes #1710
Closes #1711