🛡️ Sentinel: [MEDIUM] Add explicit timeouts to external fetch calls - #42
🛡️ Sentinel: [MEDIUM] Add explicit timeouts to external fetch calls#42felirami wants to merge 1 commit into
Conversation
This adds timeouts to fetch calls across the network, market, and github source sync logic using AbortSignal.timeout(). 🚨 Severity: MEDIUM 💡 Vulnerability: Missing fetch timeouts on external API calls 🎯 Impact: Could cause application hanging or memory exhaustion due to slow network requests. 🔧 Fix: Add `signal: AbortSignal.timeout(TIMEOUT_MS)` to explicitly stop fetches if they take too long. ✅ Verification: Ran `npm run lint`, `npm run typecheck`, and `npm run build` which passed without error. 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.
|
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 814bfb028d
ℹ️ 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.
Keep network status fetches memoized
On the server-rendered home and /network pages, NetworkStatusGrid calls getNetworkStatus() and getNodeHealthStatuses() in the same render, and the first known node probes the same /v1/info URL; /network also calls getNetworkStatus() before rendering the grid. Passing a fresh AbortSignal opts these GETs out of Next's request memoization, so a cache miss now sends duplicate public-node requests per render instead of sharing one. Keep the timeout in a shared/cached helper or reuse the first public-node result so the hardening doesn't increase upstream load.
Useful? React with 👍 / 👎.
User description
This adds explicit timeouts to all fetch calls in the codebase to prevent potential Denial-of-Service vulnerabilities from long-running or stalled network requests.
🚨 Severity: MEDIUM
💡 Vulnerability: Missing fetch timeouts on external API calls could result in indefinite hanging requests.
🎯 Impact: An unresponsive external API could cause the Next.js server to hang or exhaust memory due to unclosed fetch requests.
🔧 Fix: Used Node 20's
AbortSignal.timeout(TIMEOUT_MS)to explicitly cap request lengths.✅ Verification: Verified using
npm run lint,npm run typecheck, andnpm run build.PR created automatically by Jules for task 6284980928893417545 started by @felirami
Note
Low Risk
Defensive reliability change with bounded failure behavior; no auth or data-model changes, though slow-but-valid responses may now fail after 10s.
Overview
Adds 10s
AbortSignal.timeoutcaps on outboundfetchcalls so stalled GitHub, node info, and Dexscreener requests cannot hang indefinitely.The GitHub sync script (
fetchGithubJson/fetchGithubText) gets a sharedFETCH_TIMEOUT_MS. Runtime paths wire timeouts intogetNetworkStatusinnetwork.ts(node health checks already usedNODE_PROBE_TIMEOUT_MS) andgetSnapMarketDatavia newMARKET_FETCH_TIMEOUT_MS. A Sentinel note in.jules/sentinel.mdrecords the pattern for future reviews.Existing try/catch paths should surface abort/timeout errors as before rather than leaving connections open.
Reviewed by Cursor Bugbot for commit 814bfb0. Bugbot is set up for automated code reviews on this repo. Configure here.
CodeAnt-AI Description
Add timeouts to external API requests
What Changed
Impact
✅ Fewer hung requests✅ Lower risk of server resource exhaustion✅ Clearer failures when external services stop responding💡 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 explicit 10s timeouts to external fetch calls in sync, network, and market modules
Node.js
fetchhas no default timeout, so calls could hang indefinitely. This PR addsAbortSignal.timeout()to all external fetch calls across three areas:scripts/sync-sources.mjs: addsFETCH_TIMEOUT_MS = 10_000and applies it tofetchGithubJsonandfetchGithubTextsrc/lib/network.ts: appliesAbortSignal.timeout(NODE_PROBE_TIMEOUT_MS)to thegetNetworkStatusprobesrc/lib/snap-market.ts: addsMARKET_FETCH_TIMEOUT_MS = 10_000and applies it togetSnapMarketDataok:falsewith an abort error message instead of hangingMacroscope summarized 814bfb0.