Skip to content

fix: note consume issues: batch consume, mutex contention, stuck transactions#133

Open
zacnider wants to merge 1 commit into0xMiden:mainfrom
zacnider:fix/consume-issues
Open

fix: note consume issues: batch consume, mutex contention, stuck transactions#133
zacnider wants to merge 1 commit into0xMiden:mainfrom
zacnider:fix/consume-issues

Conversation

@zacnider
Copy link
Copy Markdown

@zacnider zacnider commented Feb 21, 2026

Summary

This PR fixes three critical note consume issues in the Miden Wallet Chrome extension:

  1. Notes from faucet fail to consume or consume very late - AutoSync (3s polling) and claimable notes polling (5s) compete with consume transactions for the single WASM AsyncMutex, starving consume operations
  2. Multiple incoming notes pile up in the queue - Each note creates a separate ConsumeTransaction, processing sequentially through the mutex bottleneck
  3. Stuck transactions block the entire queue - A transaction stuck in GeneratingTransaction state blocks all subsequent transactions indefinitely (30min timeout on desktop)

Changes

Fix 1: Pause AutoSync during consume on all platforms

  • Removed the isMobile() guard so AutoSync pauses on desktop too when transaction modal is open

Fix 2: Pause claimable notes polling during consume

  • Set SWR refreshInterval to 0 when isTransactionModalOpen is true
  • Updated notesBeingClaimed filter to support batch noteIds

Fix 3: Batch consume - multiple notes in a single transaction

  • ConsumeTransaction now accepts ConsumableNote[] and stores noteIds: string[]
  • SDK interface uses full noteIds array (SDK already supports Note[])
  • Added initiateBatchConsumeTransaction() for single batch transaction
  • "Claim All" creates one transaction instead of N separate ones

Fix 4: Auto-cancel stuck transactions in processing loop

  • Detects transactions stuck in GeneratingTransaction state and auto-cancels them

Fix 5: Reduce desktop stuck transaction timeout (30min → 5min)

Test plan

  • Request tokens from faucet → verify note is consumed quickly
  • Multiple notes → "Claim All" creates a single batch transaction
  • Verify AutoSync pauses during consume (console log)
  • Stuck transaction auto-cancels after ~1 minute
  • Build succeeds: yarn build:extension

…tuck tx recovery

- Pause AutoSync on all platforms during consume (not just mobile) to eliminate
  WASM mutex contention between sync and consume operations
- Pause claimable notes polling during consume (refreshInterval=0 when modal open)
- Add batch consume: "Claim All" now creates a single transaction for all notes
  instead of N separate transactions, leveraging SDK's newConsumeTransactionRequest(Note[])
- Fix stuck transaction blocking entire queue: auto-cancel transactions stuck in
  GeneratingTransaction state for >1 minute, allowing queued transactions to proceed
- Reduce desktop stuck transaction timeout from 30 minutes to 5 minutes
- Add noteIds[] support to ConsumeTransaction for batch operations
- Update verifyStuckTransactionsFromNode and completeConsumeTransaction for batch support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant