Skip to content

Flare: Add timeout and error handling to Oracle proxy fetches#716

Draft
adhamhaithameid wants to merge 1 commit into
mainfrom
flare-oracle-timeout-8420865582521329841
Draft

Flare: Add timeout and error handling to Oracle proxy fetches#716
adhamhaithameid wants to merge 1 commit into
mainfrom
flare-oracle-timeout-8420865582521329841

Conversation

@adhamhaithameid

Copy link
Copy Markdown
Owner

🌩️ Flare — Cloudflare Worker Security & Performance
Agent: Flare | Day: Monday | Date: 2026-07-06


🚨 Severity

PERFORMANCE

🌩️ Finding

cloudflare-worker/src/index.ts had multiple fetch() calls to upstream Oracle targets without timeouts (specifically handleOraclePublicWebsiteProxy and fetchOracleSnapshotPayload). 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 AbortController and setTimeout for both upstream fetch paths. Added try/catch/finally blocks to correctly clear the timeout and throw a standardized error (oracle_fetch_failed with the native cause attached) to ensure downstream circuit breakers and snapshot fallbacks are triggered correctly.

✅ Verification

Verified via:

  • pnpm run typecheck
  • pnpm run lint
  • pnpm run test:smoke (in cloudflare-worker and at the root)
  • pnpm run test (in cloudflare-worker)

📋 Notes

A journal entry was appended to .jules/flare.md.


PR created automatically by Jules for task 8420865582521329841 started by @adhamhaithameid

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.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cloudflare-worker/src/index.ts 90.90% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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