fix(arkade): dispose unused ContractWatcher to stop log flood#3932
Merged
Conversation
ArkadeClient polls for state (getTransaction/getVtxos) and never consumes the SDK's live contract events, but Wallet.create starts a background ContractWatcher anyway. On our Node 20 runtime the watcher has no global EventSource and the SDK's resubscribe path loops on a stale subscription id, flooding dfx-api logs on dev and prod (~1.6k errors/hr combined) with "EventSource is not defined" and "subscription not found". Stop the watcher right after wallet creation via the public ContractManager.dispose(). Best-effort and non-fatal — all wallet operations dfx-api actually uses (send/balance/vtxo/status) are unaffected.
8112561 to
ecbc249
Compare
TaprootFreak
approved these changes
Jun 18, 2026
This was referenced Jun 18, 2026
TaprootFreak
added a commit
that referenced
this pull request
Jun 18, 2026
…e + Log-Flut) (#3935) * fix(arkade): EventSource-Polyfill für Node-Runtime Das @arkade-os/sdk öffnet seine Settlement- (Batch-) und Contract-Event-Streams über ein globales EventSource. Node liefert EventSource nur hinter dem Flag --experimental-eventsource, daher warf jeder Stream auf unserer Runtime ReferenceError: EventSource is not defined. Folgen auf PRD: der periodische VTXO-Settle (alle ~5 Min) schlug hart fehl (Boarding-UTXOs wurden nicht eingebucht, ablaufende VTXOs nicht erneuert) und flutete die Logs; zusätzlich der ContractWatcher-Boot-Fehler. Fix: WHATWG-konformes eventsource@4 als globalen Polyfill in einem polyfills.ts registrieren, das in main.ts als Erstes importiert wird (vor jedem SDK-Code). Behebt beide Fehlerquellen an der Wurzel, ohne Node-Upgrade oder experimentelle Flags. Der ContractWatcher-Dispose (#3932) bleibt korrekt, da der Watcher ungenutzt ist. * test(arkade): sichere EventSource-Polyfill-Registrierung ab Fängt einen stillen Regress ab: ändert ein künftiger eventsource-Major die Export-Form, würde der Polyfill undefined registrieren und die SDK-Streams wieder werfen, ohne dass es jemand bemerkt.
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
dfx-apilogs are flooded by the Arkade integration on both dev and prod (~1.6k errors/hr combined), in two forms:Subscription error: ReferenceError: EventSource is not definedContractWatcher connection failed: ... {"code":13,"message":"subscription not found: <uuid>"}Wallet.create(@arkade-os/sdk) starts a background ContractWatcher that streams live VTXO/contract events over SSE.ArkadeClientnever uses those events — it polls for state (getTransaction→finalizePendingTxs/getVtxos). So the watcher is pure dead weight, and it's broken in our runtime:node:20-alpine), which has no globalEventSource(added in Node 22) → the SSE listen loop throwsReferenceError./subscription\s+\S+\s+not\s+found/i) doesn't match the server'ssubscription not found: <id>message → it loops forever on the dead id.Net effect is log noise only — no broken functionality, since
ArkadeClientdoesn't consume watcher events — but it drowns the logs and masks real errors.Fix
Stop the watcher right after wallet creation via the SDK's public
ContractManager.dispose(). Disposal setsisWatching=false, soconnect()/scheduleReconnect()short-circuit and the loop ends. It's wrapped best-effort (never fatal) so a transient indexer hiccup can't break wallet init.All wallet operations
ArkadeClientactually uses —getAddress,getBalance,getVtxos,sendBitcoin,finalizePendingTxs— are unaffected (dispose()only stops the live SSE watch, not the manager's data access).Test
arkade-client.spec.ts+arkade.service.spec.ts: 30/30 pass (mocks updated withgetContractManager).nest build(tsc) green against@arkade-os/sdk@0.4.36; eslint + prettier clean.Verify after merge
On dfxdev/dfxprd
dfx-api:EventSource is not definedandsubscription not founddrain to ~0.