Skip to content

fix(wallet-toolbox): ProcessSyncChunkResult.error is declared but never set or read #542

Description

@E-Jacko

Area

Wallet

Affected package or service and version

@bsv/wallet-toolboxsrc/sdk/WalletStorage.interfaces.ts:718, src/storage/WalletStorageManager.ts. Current on main at 82ab4d3c.

Defect

ProcessSyncChunkResult declares an error member:

// WalletStorage.interfaces.ts:718
error?: WalletError

No consumer reads it and no producer sets it:

  • Both chunk loops in WalletStorageManager (syncToWriter, syncFromReader) consume r.inserts, r.updates, r.done and r.nextCheckpoint. Occurrences of r.error in that file: 0.
  • EntitySyncState.processSyncChunk's declared return type is { done, maxUpdated_at, updates, inserts } — no error member at all — and StorageProvider.processSyncChunk returns that plus nextCheckpoint. So the local path cannot populate it.
  • StorageClientBase.processSyncChunk deserializes whatever the server returned into the same interface, but the server calls the same StorageProvider method, so it cannot populate it either.
  • For cross-implementation confirmation, go-wallet-toolbox's ProcessSyncChunkResult struct is Done / MaxUpdatedAt / Updates / Inserts with no Error field; Go propagates failures through its ordinary error return.

So the field is declared in one implementation, absent in the other, never set by either, and read by nobody.

Minimal reproduction

Static: grep -c "r\.error" src/storage/WalletStorageManager.ts0, while error?: WalletError is declared on the interface.

Expected behavior

Either remove the field, or specify who sets it and have both loops act on it. As written it is a declared failure channel that silently does nothing.

Actual behavior and evidence

A third-party writer implementing this interface could reasonably populate error to report a non-throwing failure, and both loops would ignore it: neither sets done, so the loop would re-request the same chunk. I am not claiming this happens today — no shipped implementation can populate the field. This is an interface-hygiene report, not a livelock report.

Environment

Static analysis of main at 82ab4d3c, cross-checked against bsv-blockchain/go-wallet-toolbox.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions