Repository navigation
fix: bound and make resumable the EVM, Solana and CKB announcement fetchers - #284
Bolajiomo99 wants to merge 5 commits into
Conversation
…tchers The three non-Stellar fetchers had no shared timeout or AbortSignal, and their pagination was unbounded, fixed to one provider page, or a serial transaction walk. They now share one options shape and error set while keeping each upstream's paging model: timeouts and caller cancellation, retry/backoff for 429/5xx and retryable RPC failures, page and item budgets with partial progress, cursor validation/repetition guards, resumable cursors, and bounded transaction concurrency for Solana. Budget exhaustion exposes the cursor for resuming, and the EVM/Solana/CKB errors are consistent without pretending the pagination models are identical. Adds tests for timeout, abort, HTTP/RPC errors, rate limits, malformed and repeated cursors, page exhaustion, partial progress and resume, plus error and compatibility docs and refreshed API/size reports.
|
@Bolajiomo99 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! 🚀 |
truthixify
left a comment
There was a problem hiding this comment.
Head 36cac7f screened clean for the known malware indicators; linked issue #271 is assigned to PR author @Bolajiomo99. Changes requested: when maxItems is exhausted mid-page, collectAnnouncementPages retains only a prefix but reports the provider cursor for the whole page. Resuming from that cursor skips the unconsumed suffix and loses announcements. Return a cursor at the exact consumed boundary or size page requests to the remaining item budget, with a regression proving stop/resume returns every record exactly once.
Closes #271
Summary
The EVM, Solana and CKB announcement fetchers could loop or allocate without limit: no request timeout, no cancellation, no page/item budget, no provider-error classification and no way to resume after a partial run. Only Stellar had bounded helpers.
This PR puts all three non-Stellar fetchers on one shared bounded-fetch foundation and keeps their pagination models honestly distinct instead of pretending they are the same.
Changes
Shared module —
src/chains/announcementFetch.ts(new)AnnouncementFetchOptions/AnnouncementPaginationOptionswith finite defaults:maxPages100,maxItems10 000, 10 s connect timeout, 30 s request timeout, 2 retries, 250 ms base delay capped at 10 s, retryable statuses[429, 500, 502, 503, 504].AbortSignal+ per-request timeout raced against the fetch, so a hung provider cannot stall a scan.Retry-After.collectAnnouncementPageswith cursor validation and a hard stop at the page/item budget;runBoundedOperationandmapWithConcurrencyfor bounded parallel work.Chain fetchers
src/chains/evm/announcements.ts): boundedskippagination, GraphQLerrors[]surfaced as provider errors, resumable decimal skip cursor, newfetchAnnouncementsPage.src/chains/solana/announcements.ts): bounded signature pagination, opaque{ v: 1, program, before }cursor, bounded transaction-fetch concurrency (concurrencyoption), rate-limit retries, newfetchAnnouncementsPage.src/chains/ckb/announcements.ts): bounded indexer cursor pagination with repeated-cursor detection, JSON-RPC error mapping, newfetchStealthCellsPage.chain, optional URL) remain backward compatible; options may be passed as the second or third argument.Typed errors (
src/errors.ts)All extend
WraithNetworkError:AnnouncementBudgetExceededError— carriespartialresults and the last goodcursorso work is resumable.AnnouncementCursorError—malformed | repeated | missing.AnnouncementProviderError— HTTP/RPC/GraphQL failures with status/details.AnnouncementResponseError— shape/decoding failures.Exported from the root entry point and from
chains/evm,chains/solanaandchains/ckb.Tests
33 new tests (
test/chains/{evm,solana,ckb}/announcements.test.ts— 12 EVM, 9 Solana, 12 CKB) covering:Retry-AfterretryDocs / generated artifacts
docs/errors.md— new error classes documented.COMPAT.md— regenerated withpnpm compat:doc.BUNDLE_SIZE.mdandpackage.jsonsize limits — budgets raised minimally to fit the new code.etc/sdk*.api.md— API reports refreshed.Verification
pnpm buildpnpm test(full suite, including companion packages)pnpm format:checkpnpm test:typespnpm api:checkpnpm sizeRe-verified on the pushed commit
c9cf236: 33/33 new tests pass, build andtest:typessucceed.Notes for reviewers
skip, Solana on a program/signature cursor, CKB on an opaque indexer cursor. The shared layer only carries what is genuinely common (bounds, deadlines, retries, error taxonomy).