Conversation
…stion 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 · |
| "X-GitHub-Api-Version": "2022-11-28", | ||
| ...(githubToken ? { Authorization: `Bearer ${githubToken}` } : {}), | ||
| }, | ||
| signal: AbortSignal.timeout(GITHUB_TIMEOUT_MS), |
There was a problem hiding this comment.
Suggestion: Adding a hard timeout here makes optional: true calls fail the whole sync on transient network slowness, because aborts throw before your optional-status handling runs. Handle timeout/abort errors in fetchGithubJson when optional is true and return null so optional data fetches degrade gracefully instead of terminating the script. [api mismatch]
Severity Level: Major ⚠️
- ⚠️ Scheduled `sync-farcasterorg-sources` GitHub Action can fail.
- ⚠️ `src/data/farcasterorg-sources.json` snapshot may not refresh.
- ⚠️ Docs and node metadata in site can become stale.
- ⚠️ Optional repo-tree enrichment can now abort whole sync.Steps of Reproduction ✅
1. From `package.json:11`, run the sync script via `npm run sync:sources`, which executes
`node scripts/sync-sources.mjs` and calls `main()` defined at
`scripts/sync-sources.mjs:247-255`.
2. Inside `main()`, the script iterates repositories and calls `buildRepoSnapshot(repo)`
at `scripts/sync-sources.mjs:254`, which in turn invokes `getRepoTree(repo.name,
defaultBranch)` at `scripts/sync-sources.mjs:182`.
3. `getRepoTree()` calls `fetchGithubJson(...)` with `{ optional: true }` at
`scripts/sync-sources.mjs:152-155`, expecting that missing tree data is treated as
optional and returning `tree?.tree ?? []` at `scripts/sync-sources.mjs:157` rather than
failing the whole run.
4. When the GitHub `git/trees` API endpoint is slow or hangs longer than 10 seconds, the
call in `fetchGithubJson()` at `scripts/sync-sources.mjs:29-37` uses `signal:
AbortSignal.timeout(GITHUB_TIMEOUT_MS)` at line 36, causing an `AbortError` to be thrown
before the `(response.status === 404 || response.status === 409) && optional` fallback at
`scripts/sync-sources.mjs:39-41` can run; because no caller catches this abort, the
promise from `getRepoTree()` rejects, `buildRepoSnapshot()` never completes, and `main()`
crashes, terminating the sync instead of degrading gracefully for this optional GitHub
request.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** scripts/sync-sources.mjs
**Line:** 36:36
**Comment:**
*Api Mismatch: Adding a hard timeout here makes `optional: true` calls fail the whole sync on transient network slowness, because aborts throw before your optional-status handling runs. Handle timeout/abort errors in `fetchGithubJson` when `optional` is true and return `null` so optional data fetches degrade gracefully instead of terminating the script.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| "X-GitHub-Api-Version": "2022-11-28", | ||
| ...(githubToken ? { Authorization: `Bearer ${githubToken}` } : {}), | ||
| }, | ||
| signal: AbortSignal.timeout(GITHUB_TIMEOUT_MS), |
There was a problem hiding this comment.
Suggestion: This timeout introduces the same contract break for optional text fetches: an abort throws and exits main() instead of returning an empty string for non-critical content. Catch timeout/abort in fetchGithubText and return "" when optional is true to preserve the function’s optional semantics. [api mismatch]
Severity Level: Major ⚠️
- ⚠️ Daily source sync workflow can terminate on slow GitHub.
- ⚠️ Optional README and docs content can crash pipeline.
- ⚠️ Docs navigation and public node metadata may not update.
- ⚠️ Upstream timeout breaks established optional-text contract.Steps of Reproduction ✅
1. Invoke the source sync pipeline via `npm run sync:sources` (script wired in
`package.json:11`), which runs `scripts/sync-sources.mjs` and enters `main()` at
`scripts/sync-sources.mjs:247-255`.
2. For each repository, `main()` calls `buildRepoSnapshot(repo)` at
`scripts/sync-sources.mjs:254`; inside this function, optional README and docs content is
fetched via `fetchGithubText(..., { optional: true })` at
`scripts/sync-sources.mjs:179-181`, `190-195`, and `200-211`, and in the docs case further
processed by `enrichDocsLinks()` at `scripts/sync-sources.mjs:213`.
3. `enrichDocsLinks()` at `scripts/sync-sources.mjs:54-87` calls `fetchGithubText(...)`
with `{ optional: true }` at `scripts/sync-sources.mjs:59-62` and then checks `if
(!markdown)` at `scripts/sync-sources.mjs:64-66` to push placeholder entries when optional
content is missing, relying on the function’s contract to return an empty string for
non-critical failures.
4. If any of the GitHub raw-content endpoints (README, SUMMARY.md, introduction.md,
getting-started.md, or per-link markdown) are slow or hang beyond 10 seconds, the
`fetchGithubText()` implementation at `scripts/sync-sources.mjs:51-70` uses `signal:
AbortSignal.timeout(GITHUB_TIMEOUT_MS)` at line 58, causing an `AbortError` before the
`(response.status === 404 || response.status === 409) && optional` fallback at
`scripts/sync-sources.mjs:61-63` executes; this abort is not caught, so
`fetchGithubText()` rejects instead of returning `""`, which bubbles through
`enrichDocsLinks()` and `buildRepoSnapshot()` to `main()`, making the Node process exit
with an uncaught abort and preventing `src/data/farcasterorg-sources.json` from being
regenerated.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** scripts/sync-sources.mjs
**Line:** 58:58
**Comment:**
*Api Mismatch: This timeout introduces the same contract break for optional text fetches: an abort throws and exits `main()` instead of returning an empty string for non-critical content. Catch timeout/abort in `fetchGithubText` and return `""` when `optional` is true to preserve the function’s optional semantics.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
User description
🚨 Severity: MEDIUM
💡 Vulnerability: External
fetchcalls in Next.js backend routes (/api/network-status,/api/snap-market) and static generation scripts (scripts/sync-sources.mjs) lacked explicit timeouts. By default, the nativefetchAPI does not time out, meaning network hangs or unresponsive third-party APIs (like Dexscreener, GitHub, or public nodes) could cause server routes and builds to hang indefinitely, exhausting server resources and leading to Denial of Service (DoS).🎯 Impact: Unresponsive external services could cause the Hypersnap API endpoints to hang indefinitely, leading to resource exhaustion (e.g., connection pool depletion, high memory usage) and bringing down the Next.js server or hanging the build process.
🔧 Fix: Added explicit timeouts to all external
fetchcalls usingsignal: AbortSignal.timeout(TIMEOUT_MS):10_000msfor GitHub API calls insync-sources.mjs.10_000msfor the public Farcaster node info probe innetwork.ts.10_000msfor the Dexscreener API insnap-market.ts.✅ Verification: Ran
npm run lint,npm run typecheck, andnpm run build. Verified that the build completes successfully without errors. Tested thatNODE_PROBE_TIMEOUT_MSwas already correctly defined insrc/lib/network.ts.PR created automatically by Jules for task 1927136245366074214 started by @felirami
Note
Low Risk
Small, defensive networking change with no auth or data-model impact; worst case is earlier failures when third parties are slow.
Overview
Adds 10s
AbortSignal.timeoutguards on outboundfetchcalls that previously could hang indefinitely when GitHub, Dexscreener, or the public node probe stalls.scripts/sync-sources.mjsintroducesGITHUB_TIMEOUT_MSand applies it to bothfetchGithubJsonandfetchGithubText.getNetworkStatusinnetwork.tsnow uses the existingNODE_PROBE_TIMEOUT_MSon its info probe.snap-market.tsaddsMARKET_TIMEOUT_MSfor the Dexscreener market fetch.Existing error handling paths (e.g. timeout messaging in
network.ts) should surface failures instead of leaving builds or API routes blocked on slow peers.Reviewed by Cursor Bugbot for commit 043c27c. Bugbot is set up for automated code reviews on this repo. Configure here.
CodeAnt-AI Description
Add timeouts to external fetches so slow services don't hang the app
What Changed
Impact
✅ Fewer hanging API requests✅ Faster failure when third-party services are slow✅ Lower risk of build or server resource exhaustion💡 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 10-second timeouts to external fetch calls to prevent server resource exhaustion
AbortSignal.timeout(10000)to GitHub JSON and text fetches in sync-sources.mjs; requests now reject with anAbortErrorinstead of hanging indefinitely.AbortSignal.timeout(NODE_PROBE_TIMEOUT_MS)to the node probe fetch in network.ts; timeouts now returnok=falsewith the timeout error message.AbortSignal.timeout(10000)to the market data fetch in snap-market.ts; timeouts return an error response withok=false.📊 Macroscope summarized 043c27c. 3 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.