Skip to content

Commit 479b8e1

Browse files
committed
fix(API): remove redundant walletIsSynced call that raced on error slot
getWalletHealthResponse already calls walletIsSynced internally, so the parallel direct call doubled RPC load and raced on the module-level lastWalletSyncError variable (each call clears it to null). Derive synced from the wallet health response instead.
1 parent 257ab85 commit 479b8e1

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

src/routes/diagnostics.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ export const getDiagnosticsResponse = async () => {
257257
const rpcSettles = [
258258
settle('wallet.getActiveNetwork', () => wallet.getActiveNetwork(), DEFAULT_TIMEOUT_MS),
259259
settle('wallet.getChiaVersion', () => wallet.getChiaVersion(), DEFAULT_TIMEOUT_MS),
260-
settle('wallet.walletIsSynced', () => wallet.walletIsSynced(), DEFAULT_TIMEOUT_MS),
261260
settle('wallet.getWalletBalance', () => wallet.getWalletBalance(), DEFAULT_TIMEOUT_MS),
262261
settle('wallet.getWalletConnections', () => wallet.getWalletConnections(), DEFAULT_TIMEOUT_MS),
263262
settle(
@@ -285,7 +284,6 @@ export const getDiagnosticsResponse = async () => {
285284
const [
286285
activeNetworkRes,
287286
chiaVersionRes,
288-
walletSyncedRes,
289287
walletBalanceRes,
290288
walletConnectionsRes,
291289
walletHealthRes,
@@ -306,13 +304,10 @@ export const getDiagnosticsResponse = async () => {
306304
// ground-truth reachability probe.
307305
const walletReachable = activeNetworkRes.ok && activeNetworkRes.value !== false;
308306

309-
// lastWalletSyncError is a module-level slot in wallet.js that walletIsSynced
310-
// overwrites on every call. It's our best signal for the SPECIFIC connection
311-
// error (ECONNREFUSED, ETIMEDOUT, etc.) but it can be `null` if a
312-
// concurrent caller cleared it after our walletIsSynced returned. When the
313-
// wallet is unreachable but the slot is empty, we fall back to a synthetic
314-
// message so operators looking at the JSON always know unreachability is
315-
// distinct from "reachable but unsynced".
307+
// walletIsSynced() is called internally by getWalletHealthResponse, which
308+
// populates the module-level lastWalletSyncError slot. We read it here for
309+
// the specific error message (ECONNREFUSED, ETIMEDOUT, etc.) and fall back
310+
// to a synthetic message when the slot is empty.
316311
const walletConnectionError = wallet.getLastWalletSyncError?.();
317312

318313
const enableV1 = configV1?.ENABLE !== false;
@@ -391,7 +386,7 @@ export const getDiagnosticsResponse = async () => {
391386
rpcUrl: appConfig.WALLET_URL || null,
392387
reachable: walletReachable,
393388
connectionError: walletConnectionErrorMessage,
394-
synced: walletSyncedRes.ok ? walletSyncedRes.value === true : false,
389+
synced: walletHealthRes.ok ? walletHealthRes.value?.synced === true : false,
395390
balanceXch:
396391
walletReachable && walletBalanceRes.ok && walletBalanceRes.value !== false
397392
? walletBalanceRes.value

0 commit comments

Comments
 (0)