feat: add Spark SDK debug logging patch#964
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
orveth
left a comment
There was a problem hiding this comment.
looks good overall — clean gating pattern, no sensitive data logged, patch registration is correct.
one thing caught my eye: in the getBalance() patch, owned and incoming are assigned before addLeaves/evictStaleAvailable but the original code called getOwnedBalance()/getIncomingBalance() after those calls (inline in the return). does the ordering matter here? if eviction changes what those return, the debug patch would report pre-eviction values. might want to move those two assignments below evictStaleAvailable to match the original call timing.
otherwise this is a clean diagnostic patch — good to go once that's checked.
…tics Patches @buildonspark/spark-sdk to add debug logs (gated behind globalThis.__SPARK_SDK_DEBUG__) in setupBackgroundStream, handleStreamEvent, getBalance, and syncWallet. The flag is set from the DEBUG_LOGGING_SPARK feature flag in entry.client.tsx. This helps diagnose stale balance issues on mobile where the gRPC event stream may die during background, causing the leaf cache to miss new transfers and getBalance() to return stale `owned` values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dc5c0a4 to
e606063
Compare
@orveth I think you are wrong. The patch logs values before and after those calls, unless I am missing something |
|
will close and reopen because gh actions seem stuck |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@gudnuf I am merging this (and merged one more before) without waiting for your approval because these are just minor log changes |
Summary
@buildonspark/spark-sdk@0.7.1with debug logs gated behindglobalThis.__SPARK_SDK_DEBUG__DEBUG_LOGGING_SPARKfeature flag inentry.client.tsxgetBalance()(owned vs available vs fresh coordinator leaves), andsyncWallet()Context
Investigating stale Spark balance on mobile after receive. Root cause hypothesis: the SDK's gRPC event stream dies during mobile background, retries may reconnect but don't call
syncWallet(), so the leaf cache misses transfers from the gap period.getBalance().ownedreads from stale cache while.availableis fresh from the coordinator.These logs (prefixed
[Spark SDK]) will confirm whether:owneddiverges fromavailableafter reconnectionFiles changed
patches/@buildonspark%2Fspark-sdk@0.7.1.patch— SDK debug logging patchapp/entry.client.tsx— setsglobalThis.__SPARK_SDK_DEBUG__from feature flagpackage.json/bun.lock— patch registrationTest plan
DEBUG_LOGGING_SPARKflag, open app[Spark SDK]logs appear in console (stream setup, getBalance calls)owneddiverges fromavailable🤖 Generated with Claude Code