For the complete documentation index, see llms.txt
Troubleshoot wallet sync stalls
Use this page when a wallet built with the Wallet SDK starts but never reports synced. waitForSyncedState() doesn't return, or isSynced stays false on Preprod or Mainnet while the same code finishes syncing on a local network.
A slow first sync often looks like a stall. Start by checking your SDK version and watching the wallet's progress, then find the symptom that matches.
Check the Wallet SDK version
Preprod, Preview, and Mainnet run ledger 9. Wallets on Wallet SDK 1.x, including 1.2.0, can't transact on them. Install the Wallet SDK version listed in the compatibility matrix before you debug anything else:
npm ls @midnightntwrk/wallet-sdk @midnightntwrk/wallet-sdk-facade
The rest of this page describes Wallet SDK 2.0.1, which ships @midnightntwrk/wallet-sdk-facade 5.0.1 and @midnightntwrk/wallet-sdk-dust-wallet 5.1.0. If you install the wallet packages one by one instead of @midnightntwrk/wallet-sdk, then check those versions.
What isSynced waits for
A WalletFacade holds three wallets: shielded, unshielded, and DUST. isSynced on the facade state is true only when all three report that they're complete, and waitForSyncedState() waits for each of them. One slow wallet holds back the whole facade.
Each wallet is complete when both of these hold:
- It's connected to the indexer.
- It has applied every event up to the highest one that the indexer reported as relevant to it.
The unshielded wallet also checks the indexer against the node. When the configuration has a node address, the wallet compares the indexer's latest block with the node's finalized block. It doesn't report synced before the first check finishes. It also waits while the indexer is behind the node, or while the two are on different networks.
Tell a slow sync from a stalled one
Log each wallet's progress once a minute. A slow sync keeps moving: the applied number grows toward the target. A stalled sync stops moving.
import * as Rx from 'rxjs';
const progressLog = wallet
.state()
.pipe(Rx.throttleTime(60_000))
.subscribe((s) => {
const shielded = s.shielded.progress;
const unshielded = s.unshielded.progress;
const dust = s.dust.progress;
console.log(new Date().toISOString(), {
synced: s.isSynced,
shielded: `${shielded.appliedIndex}/${shielded.highestRelevantWalletIndex} connected=${shielded.isConnected}`,
unshielded: `${unshielded.appliedId}/${unshielded.highestTransactionId} connected=${unshielded.isConnected} indexer=${unshielded.indexerLiveness._tag}`,
dust: `${dust.appliedIndex}/${dust.highestRelevantWalletIndex} connected=${dust.isConnected}`,
});
});
wallet is your WalletFacade. Call progressLog.unsubscribe() when you no longer need the log. Read the output this way:
- A number that grows between lines: the wallet is still syncing. Leave it running. See First sync takes hours.
indexer=Behindorindexer=WrongNetworkon the unshielded wallet: see The unshielded wallet never reports synced.- A number that stops growing for many minutes, with no error: see Sync stops with no error.
First sync takes hours
A new wallet on Preprod connects within seconds, its balances appear, and isSynced stays false for hours.
Cause: The DUST wallet replays every DUST event on the chain, not only the events for your addresses. Preprod and Mainnet moved to ledger 9 in place, so their DUST history includes all the events from before the upgrade. A local network has a short history, which is why the same code syncs much sooner there.
Fix: Keep the process running until the first sync finishes. A process that restarts without a saved wallet state syncs again from the start.
For a new wallet, you can skip the DUST history from before ledger 9 with the skipLedgerV8DustHistory option. This snippet changes only the dust line of the WalletFacade.init call in Building a wallet from a seed:
const wallet = await WalletFacade.init({
configuration,
shielded: (config) => ShieldedWallet(config).startWithSeed(seeds.shielded),
unshielded: (config) => UnshieldedWallet(config).startWithPublicKey(PublicKey.fromKeyStore(unshieldedKeystore)),
dust: (config) => DustWallet({ ...config, skipLedgerV8DustHistory: true }).startWithSeed(seeds.dust),
});
await wallet.start(seeds);
The option has these limits:
- It applies only to a wallet that starts from a seed. A wallet that you restore from a saved state resumes where that state left off.
- The wallet has no DUST transaction history from before ledger 9.
- It changes only the DUST wallet. The shielded and unshielded wallets still read the history from before ledger 9, because they need it to find the coins that they hold.
- It's best effort. On a chain that started on ledger 9, or when the indexer search finds nothing or doesn't answer in time, the wallet starts as it would without the option.
With Wallet SDK 2.0.1, the search through the Blockfrost Preprod indexer can take longer than the 30 seconds the wallet waits for it, and the wallet then replays the full history as if the option were off. Watch the DUST numbers in your progress log to see whether the option took effect. servicedesk#319 tracks this known issue.
To work around it, run the search yourself before you build the wallet, where no 30-second limit applies. Call SyncService.findDustTimelineStart from @midnightntwrk/wallet-sdk-dust-wallet/v2 with your sync configuration and the ledger 9 fork version. Then pass a function that returns its result as dustTimelineStartProbe in the DUST wallet configuration. Leave skipLedgerV8DustHistory off when you do this, because with it on, the wallet replaces your probe with its own search. dustTimelineStartProbe isn't part of the DefaultDustConfiguration type, so TypeScript needs a cast. In one Preprod test, this found the start and synced about 130,000 ledger 9 DUST events in about 4 minutes.
Repeated Wallet.Sync: [object Object] messages
The wallet prints Wallet.Sync: [object Object] again and again while it syncs.
Cause: The indexer connection failed or closed, for example during a long first sync. The SDK turns the WebSocket error into the text [object Object], so the message doesn't say what went wrong.
Fix: Keep the process running. The wallet usually retries on its own. If your progress log shows that the applied numbers keep growing between these messages, then the sync is healthy. If the numbers stop growing, then check the indexer address and your Blockfrost project ID. Both must be for the same network as the rest of your configuration.
The unshielded wallet never reports synced
The progress log shows the shielded and DUST wallets complete, but the unshielded wallet reports indexer=Behind, indexer=WrongNetwork, or indexer=Unknown and never completes.
Cause: The unshielded wallet won't report synced over an indexer that it can't trust:
Behind: the indexer is further behind the node's finalized block than the wallet accepts.WrongNetwork: the indexer and the node in your configuration belong to different networks.Unknown: the wallet hasn't finished its first comparison of the indexer and the node.
Fix: Check that indexerClientConnection and the node address (relayURL, or nodeClientConnection if you set it) point to the same network. For Preprod and Mainnet endpoints, see Networks and environments. If the indexer is behind, then wait for it to catch up or point the wallet at another indexer for the same network.
Sync stops with no error
The applied numbers stop growing for a long time, and no error appears. isSynced never becomes true.
Cause: The connection to the indexer can stay open while no events arrive. The DUST wallet doesn't notice a silent connection, so it waits for events instead of reconnecting.
Fix: Stop the wallet with await wallet.stop() and start it again. A wallet that starts again from its seed syncs from the start. To keep the progress that it already made, save each wallet's state first with serializeState(), for example await wallet.dust.serializeState(), and start each new wallet from its saved state with restore().
A restored DUST wallet fails on its first update
You start a DUST wallet from a saved state, and every sync attempt fails with an error like one of these:
values inserted non-linearly into dust commitment tree; expected to insert index 118195, but received 118183.
received an event with a timestamp prior to the time already synced to
The wallet retries, but the same error comes back on every attempt and after every restart.
Cause: The saved state records where to resume as an indexer event ID. The indexer's database assigns those IDs, so the same event can have a different ID on another indexer deployment, or after an indexer resyncs its database. When the IDs don't match, the wallet resumes at the wrong event.
Fix: Discard the saved DUST wallet state and start the DUST wallet from its seed. On a new start, you can use skipLedgerV8DustHistory to shorten the replay, as described in First sync takes hours. Keep a saved state with the indexer that it came from, and don't reuse it after you change indexer providers. For the move from the Midnight-hosted indexer to Blockfrost, see Migrating from the Midnight-hosted endpoints.
Get help
If none of these steps fixes the stall, then open a ticket at the Midnight Service Desk or ask in Discord. Include your Wallet SDK version, the network, and a few lines of the progress log.
Additional resources
- Funding a wallet builds the wallet that this page uses.
- Managing DUST covers DUST generation, balances, and fees.
- Compatibility matrix lists the supported versions for each network.