Skip to content

fix: resolve dangling timer, RPC burst, sparse array, and stale cache bugs (#550, #549, #548, #547) - #594

Open
markdavid000 wants to merge 3 commits into
conduit-protocol:mainfrom
markdavid000:fix/nonce-timer-concurrency-sparse-array-cache-key
Open

fix: resolve dangling timer, RPC burst, sparse array, and stale cache bugs (#550, #549, #548, #547)#594
markdavid000 wants to merge 3 commits into
conduit-protocol:mainfrom
markdavid000:fix/nonce-timer-concurrency-sparse-array-cache-key

Conversation

@markdavid000

Copy link
Copy Markdown

Summary

Fixes four bugs across NonceManager, StreamsModule, and Module49.

Changes

closes #550 — NonceManager.acquireWithFallback dangling setTimeout

  • Captured the setTimeout timer ID and added clearTimeout in a finally block after Promise.race.
  • Prevents the timer from keeping the Node event loop alive after a successful acquire, which delayed clean process exit and triggered open-handle warnings in tests.

closes #549 — StreamsModule.list() unbounded concurrent RPCs

  • Added a mapWithConcurrency helper that runs async tasks with a bounded worker pool (default concurrency: 8).
  • Replaced bare Promise.all fan-outs in pageFromFilteredIds for both address pre-warm and stream info fetching.
  • Prevents up to 100 concurrent simulateTransaction RPCs per page from tripping provider rate limits and causing 429s for other in-flight SDK calls.

closes #548 — Module49.processStreamBatch sparse array

  • Changed from pre-allocated array with index assignment to push() into a dense array.
  • Falsy input items are filtered out, so the returned array never contains undefined holes that crash downstream .map() / for...of iterations.

closes #547 — Module49.processSingleItem stale cache key

  • Extended the cache key to include all fields read by withdrawableLocal: cancelled, pausedAt, ratePerSecond, startTime, and endTime.
  • Previously only id, withdrawn, paused, and nowSec were in the key, causing stale cache hits when stream state changed within the same wall-clock second.

Capture the timer ID from setTimeout and call clearTimeout in a finally
block after Promise.race resolves. This prevents the timer from keeping
the Node event loop alive after a successful acquire, which could delay
clean process exit and trigger open-handle warnings in test runs.

Fixes conduit-protocol#550
Add a bounded concurrency helper (mapWithConcurrency) that processes
items with at most N in-flight async calls. Use it for both the address
pre-warm fan-out and the stream info fetching in pageFromFilteredIds.

Previously list() issued up to 100 concurrent simulateTransaction RPCs
per page via bare Promise.all, which routinely tripped provider rate
limits and caused 429s for other in-flight SDK calls sharing the
endpoint. The new default concurrency of 8 keeps throughput high while
staying well under typical rate limits.

Fixes conduit-protocol#549
…reamBatch

Two fixes in Module49:

1. Sparse array (Issue conduit-protocol#548): processStreamBatch now pushes results into
   a dense array instead of assigning to pre-allocated slots, avoiding
   undefined holes when input items are falsy. Callers iterating the
   result no longer crash with 'Cannot read properties of undefined'.

2. Stale cache key (Issue conduit-protocol#547): The processSingleItem cache key now
   includes all fields read by withdrawableLocal (cancelled, pausedAt,
   ratePerSecond, startTime, endTime) in addition to the previously
   captured id, withdrawn, paused, and nowSec. This prevents stale cache
   hits when stream state changes within the same wall-clock second.

Fixes conduit-protocol#548
Fixes conduit-protocol#547
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@markdavid000 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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