fix(proposals): add timeouts to source fetches and fix unstable_cache nesting - #2134
Open
sleyter93 wants to merge 4 commits into
Open
fix(proposals): add timeouts to source fetches and fix unstable_cache nesting#2134sleyter93 wants to merge 4 commits into
sleyter93 wants to merge 4 commits into
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
… nesting Without timeouts, hung RPC and HTTP calls (getBlockNumber, Blockscout pagination, Envio GraphQL) accumulate in the event loop during background revalidation, eventually starving the process and triggering a container restart. - Wrap getBlockNumber(config) with Promise.race + 10 s timeout in validate-source-sync.ts (both call sites) and get-proposals-from-the-graph.ts - Add AbortSignal.timeout(25_000) to each fetch() in the Blockscout while-loop pagination, matching the timeout used in the canonical Blockscout fetch module - Add AbortSignal.timeout(10_000) to the Envio GraphQL fetch - Add logger.error when a source returns [] (previously silent) and when all sources are exhausted - Fix triple-nested unstable_cache: fetchAllProposals now calls getProposalsFromBlockscoutUncached directly; transformProposalsIntoMap calls fetchAllProposals (raw) instead of getCachedProposals, so each cache wrapper only wraps raw functions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sleyter93
force-pushed
the
fix/proposal-source-timeouts
branch
from
April 29, 2026 21:53
0b621da to
b399849
Compare
…outs Adds structured timing logs to pinpoint 502 root cause during Blockscout fallback conditions. Also fixes remaining timeout gaps identified in the report. Logging added: - fetchAllProposals: concurrent revalidation counter (activeRevalidations), per-source elapsed time, total elapsed time - fetchProposalLogsFromBlockscout: page count + total elapsed on completion and on error - fetchVaultLogsAllPagesForTopic: per-topic page count + elapsed - fetchVaultLogsForTopics: total topics, merged item count, total elapsed - fetchClaimedItemsFromTheGraph: per-page timing + total, hard cap at 100 pages (was unbounded) - _lastBlockNumber (health check): db block, chain block, healthy flag, elapsed Timeouts added: - getBlockNumber in health check: 5 s Promise.race (was unbounded; ECS health check failures cause rolling restarts → 502 during replacement) - envio-sync-check all 4 fetch calls: AbortSignal.timeout(10_000) - discourse/topic fetch: AbortSignal.timeout(10_000) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When all proposal sources fail or return empty, fetchAllProposals now throws instead of returning an empty array. This prevents unstable_cache from overwriting a previously good cache entry with an empty result, which was causing users to see 0 proposals for up to 30s after a Blockscout timeout. The route now catches the throw and returns 503. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getBlockNumber(config)calls withPromise.race+ 10 s timeout (validate-source-sync.ts×2,get-proposals-from-the-graph.ts×1) — previously these wagmi RPC calls had no bound, and under a stalled RPC node they would hang indefinitelyAbortSignal.timeout(25_000)to everyfetch()inside the Blockscout pagination loop — matches the timeout used in the canonical Blockscout fetch module (fetch-blockscout-get-logs-paginated.ts)AbortSignal.timeout(10_000)to the Envio GraphQL fetchlogger.errorwhen a source returns an empty array (previously silent) and when all sources are exhausted, making last-resort failures visible in logsunstable_cache:fetchAllProposalsnow callsgetProposalsFromBlockscoutUncacheddirectly;transformProposalsIntoMapcallsfetchAllProposals(raw) instead ofgetCachedProposals, so each cache wrapper only wraps raw functionsfetch-all-proposals.test.tsmock to targetgetProposalsFromBlockscoutUncachedContext
The process was being restarted by the container orchestrator after becoming unresponsive. Root cause: accumulated hung promises from timeout-less network calls during
unstable_cachebackground revalidations (every 30 s). When the subgraph was stuck at block 7585149 (~16 k blocks behind), all three indexer-backed sources (Envio, DB, The Graph) failed, and Blockscout became the last resort — but itsfetch()calls and thegetBlockNumber()RPC calls had no timeout. Under a slow/stalled connection, these promises never settled, starving the event loop.Reviewer notes
FETCH_TIMEOUT_MSconvention), 25 s for Blockscout pagination (matchesREQUEST_TIMEOUT_MSinfetch-blockscout-get-logs-paginated.ts)