π‘οΈ Sentinel: [Medium] Add explicit timeouts to all external fetch calls - #24
π‘οΈ Sentinel: [Medium] Add explicit timeouts to all external fetch calls#24felirami wants to merge 1 commit into
Conversation
π¨ Severity: MEDIUM π‘ Vulnerability: The native \`fetch\` API does not have a default timeout. Several external API calls to Dexscreener, Farcaster public node info endpoints, and GitHub lacked explicit timeouts. π― Impact: If these external services are slow or unresponsive, requests can hang indefinitely, potentially exhausting server connections and causing denial of service (DoS) or very slow page loads. π§ Fix: Added \`signal: AbortSignal.timeout(TIMEOUT_MS)\` to all native \`fetch\` calls in \`src/lib/network.ts\`, \`src/lib/snap-market.ts\`, and \`scripts/sync-sources.mjs\`. β Verification: Ran \`npm run lint\`, \`npm run typecheck\`, and \`npm run build\` successfully to ensure no build-time or type errors were introduced. Co-authored-by: felirami <6752178+felirami@users.noreply.github.com>
|
π 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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Thanks for using CodeAnt! πWe're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X Β· |
There was a problem hiding this comment.
π‘ Medium
When optional: true is passed and the request times out, AbortSignal.timeout() causes fetch to reject with a TimeoutError before the response status is checked. This bypasses the graceful handling of 404/409 on lines 39-41, causing the entire script to crash even for optional resources like hyper.md or SUMMARY.md when GitHub is slow.
Consider catching AbortError and returning null (or the appropriate empty value) when optional is true, so timeouts don't crash the script.
π Reply "fix it for me" or copy this AI Prompt for your agent:
In file @scripts/sync-sources.mjs around line 29:
When `optional: true` is passed and the request times out, `AbortSignal.timeout()` causes `fetch` to reject with a `TimeoutError` before the response status is checked. This bypasses the graceful handling of 404/409 on lines 39-41, causing the entire script to crash even for optional resources like `hyper.md` or `SUMMARY.md` when GitHub is slow.
Consider catching `AbortError` and returning `null` (or the appropriate empty value) when `optional` is true, so timeouts don't crash the script.
Evidence trail:
scripts/sync-sources.mjs lines 29-49 (fetchGithubJson with AbortSignal.timeout on line 36, 404/409 handling on lines 39-41), lines 51-71 (fetchGithubText, same pattern), lines 346-357 (getRepoTree calls with optional:true, no try/catch), lines 359-374 (getLatestRelease, same), lines 376-444 (buildRepoSnapshot calls fetchGithubText with optional:true, no try/catch), lines 507-509 (main catch handler calls process.exit(1)). AbortSignal.timeout() behavior: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static β throws TimeoutError when deadline expires, which rejects the fetch promise before any response is available.
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96c282ec06
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| headers: { | ||
| Accept: "application/json", | ||
| }, | ||
| signal: AbortSignal.timeout(NODE_PROBE_TIMEOUT_MS), |
There was a problem hiding this comment.
Preserve fetch memoization for shared status probes
On /network, src/app/network/page.tsx:30 calls getNetworkStatus() and NetworkStatusGrid calls both getNetworkStatus() and getNodeHealthStatuses() (src/components/network-status.tsx:120-122), with the first known node using the same public /v1/info URL. Next's fetch docs state that passing a signal opts out of render-pass memoization, so when the revalidated cache entry is cold or stale this new signal turns the formerly deduped probe into multiple concurrent requests to the same external node. Please keep timeout handling in a shared cached helper or otherwise preserve memoization so the status page does not amplify load.
Useful? React with πΒ / π.
User description
π¨ Severity: MEDIUM
π‘ Vulnerability: The native
fetchAPI does not have a default timeout. Several external API calls to Dexscreener, Farcaster public node info endpoints, and GitHub lacked explicit timeouts.π― Impact: If these external services are slow or unresponsive, requests can hang indefinitely, potentially exhausting server connections and causing denial of service (DoS) or very slow page loads.
π§ Fix: Added
signal: AbortSignal.timeout(TIMEOUT_MS)to all nativefetchcalls insrc/lib/network.ts,src/lib/snap-market.ts, andscripts/sync-sources.mjs.β Verification: Ran
npm run lint,npm run typecheck, andnpm run buildsuccessfully to ensure no build-time or type errors were introduced.PR created automatically by Jules for task 13629205337412889224 started by @felirami
CodeAnt-AI Description
Add timeouts to external fetch requests to prevent hangs
What Changed
Impact
β Fewer stuck page loadsβ Lower risk of server connection exhaustionβ Clearer failures when external services are slowπ‘ Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Note
Add 15s/10s
AbortSignaltimeouts to all external fetch callsAbortSignal.timeout()to GitHub API fetches in sync-sources.mjs (15s), the node info probe in network.ts, and market data fetches in snap-market.ts (10s).ok: falsewith an error message via existing catch paths rather than hanging indefinitely.π Macroscope summarized 96c282e. 4 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
ποΈ Filtered Issues
No issues evaluated.