Skip to content

fix(twitter): add 5s network timeout to resolveTwitterQueryId#1106

Merged
jackwener merged 1 commit intojackwener:mainfrom
fuleinist:fix/twitter-article-timeout
Apr 21, 2026
Merged

fix(twitter): add 5s network timeout to resolveTwitterQueryId#1106
jackwener merged 1 commit intojackwener:mainfrom
fuleinist:fix/twitter-article-timeout

Conversation

@fuleinist
Copy link
Copy Markdown
Contributor

Fix: twitter article command hangs on network stall

Problem

The opencli twitter article command hangs indefinitely when network connectivity is unavailable. This occurs because resolveTwitterQueryId() in clis/twitter/shared.js fetches an external JSON file from GitHub without any timeout. If that fetch stalls (no response, no error), the function never resolves and the entire command hangs.

Solution

Wrap the fetch() call inside resolveTwitterQueryId() with an AbortController that aborts after 5 seconds. On timeout (or any other network error), the code falls through to the existing script-scanning fallback strategy, which uses local performance.getEntriesByType('resource') and requires no network access.

Changes

clis/twitter/shared.js — Added a 5-second AbortController timeout to the GitHub fetch. The clearTimeout is called in both the catch and after the successful response so there's no lingering timer.

Testing

  • Build passes: npm run build completes successfully
  • TypeScript compilation: npx tsc --noEmit passes
  • The change is minimal (net +6 lines) and only affects the single network call path

Related

Fixes open issue #1082

The resolveTwitterQueryId() function in shared.js fetches an external JSON
file from GitHub without a timeout. If the network request stalls, the
function never resolves and the twitter article command hangs indefinitely.

Add a 5-second AbortController timeout so the fetch fails fast and falls
back to the local script-scanning strategy. This fixes the reported hang
when opencli twitter article loses network connectivity.
@jackwener jackwener merged commit f7fd805 into jackwener:main Apr 21, 2026
11 checks passed
luxiaolei pushed a commit to luxiaolei/OpenCLI that referenced this pull request Apr 22, 2026
…jackwener#1106)

The resolveTwitterQueryId() function in shared.js fetches an external JSON
file from GitHub without a timeout. If the network request stalls, the
function never resolves and the twitter article command hangs indefinitely.

Add a 5-second AbortController timeout so the fetch fails fast and falls
back to the local script-scanning strategy. This fixes the reported hang
when opencli twitter article loses network connectivity.

(cherry picked from commit f7fd805)
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.

2 participants