Flare: Add timeout and error handling to Oracle proxy fetches#716
Flare: Add timeout and error handling to Oracle proxy fetches#716adhamhaithameid wants to merge 1 commit into
Conversation
Implements an 8-second timeout for `fetch()` calls to the Oracle backend within `cloudflare-worker/src/index.ts`. This prevents the Cloudflare Worker from hanging and consuming execution time when the backend is unresponsive. Includes proper try/catch/finally blocks to clear the timeout and throw normalized errors (`oracle_fetch_failed`) to allow downstream fallback logic to execute properly.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
🌩️ Flare — Cloudflare Worker Security & Performance
Agent: Flare | Day: Monday | Date: 2026-07-06
🚨 Severity
PERFORMANCE
🌩️ Finding
cloudflare-worker/src/index.tshad multiplefetch()calls to upstream Oracle targets without timeouts (specificallyhandleOraclePublicWebsiteProxyandfetchOracleSnapshotPayload). If the Oracle backend was slow or unresponsive, these fetches could block the event loop, causing the worker to run out of memory or exhaust its execution limits.Additionally, unhandled rejections from network failures were crashing the worker and bypassing downstream snapshot fallbacks.
🎯 Impact
Latency/cost impact. Slow Oracle responses would tie up worker resources and potentially lead to 502/503 errors across the board for end users rather than safely returning cached snapshot data.
🔧 Fix Applied
Implemented an 8-second timeout using an
AbortControllerandsetTimeoutfor both upstream fetch paths. Addedtry/catch/finallyblocks to correctly clear the timeout and throw a standardized error (oracle_fetch_failedwith the native cause attached) to ensure downstream circuit breakers and snapshot fallbacks are triggered correctly.✅ Verification
Verified via:
pnpm run typecheckpnpm run lintpnpm run test:smoke(incloudflare-workerand at the root)pnpm run test(incloudflare-worker)📋 Notes
A journal entry was appended to
.jules/flare.md.PR created automatically by Jules for task 8420865582521329841 started by @adhamhaithameid