Skip to content

fix: add 30s request timeout to withSpinner to prevent hanging CLI commands#237

Merged
felipefreitag merged 8 commits into
mainfrom
fix/spinner-request-timeout-839b
May 11, 2026
Merged

fix: add 30s request timeout to withSpinner to prevent hanging CLI commands#237
felipefreitag merged 8 commits into
mainfrom
fix/spinner-request-timeout-839b

Conversation

@bukinoshita

@bukinoshita bukinoshita commented Apr 9, 2026

Copy link
Copy Markdown
Member

Summary by cubic

Add a 30s request timeout to withSpinner so CLI commands fail fast instead of hanging when the API is slow.

  • Bug Fixes
    • Added withTimeout utility with REQUEST_TIMEOUT_MS = 30_000.
    • Wrapped SDK calls in withSpinner with the timeout; all withSpinner-based commands are now bounded.
    • Added tests for withTimeout and timeout handling in withSpinner.

Written for commit 6d98a55. Summary will update on new commits.

cursoragent and others added 3 commits April 9, 2026 17:35
…mmands

Adds a withTimeout utility that wraps SDK call promises with a 30-second
deadline. When the timeout expires, the promise rejects with a structured
error that flows through the existing error handling in withSpinner.

This prevents contact commands (and all other SDK-backed commands) from
hanging indefinitely when the upstream API is slow or unresponsive.

Resolves BU-640

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@bukinoshita

Copy link
Copy Markdown
Member Author

@cubic-dev-ai can you review?

@cubic-dev-ai

cubic-dev-ai Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai can you review?

@bukinoshita I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

@bukinoshita bukinoshita marked this pull request as ready for review April 13, 2026 23:48

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/lib/spinner.ts">

<violation number="1" location="src/lib/spinner.ts:71">
P1: Timeout handling does not cancel the underlying SDK request, so timed-out commands may still complete remotely.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread src/lib/spinner.ts Outdated
try {
for (let attempt = 0; ; attempt++) {
const { data, error, headers } = await call();
const { data, error, headers } = await withTimeout(

@cubic-dev-ai cubic-dev-ai Bot Apr 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Timeout handling does not cancel the underlying SDK request, so timed-out commands may still complete remotely.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/spinner.ts, line 71:

<comment>Timeout handling does not cancel the underlying SDK request, so timed-out commands may still complete remotely.</comment>

<file context>
@@ -67,7 +68,10 @@ export async function withSpinner<T>(
   try {
     for (let attempt = 0; ; attempt++) {
-      const { data, error, headers } = await call();
+      const { data, error, headers } = await withTimeout(
+        call(),
+        REQUEST_TIMEOUT_MS,
</file context>
Fix with Cubic

felipefreitag and others added 5 commits April 16, 2026 16:28
`test` is not imported from vitest and globals are not enabled,
causing a ReferenceError that crashes the entire spinner test file.
…imeout-839b

# Conflicts:
#	src/lib/spinner.ts
main #242 extracted retry logic into withRetry. Apply withTimeout to the
call before passing it into withRetry, so the per-attempt timeout still
holds. Replace the brittle module-spy in the spinner test with a fake-timers
test, and cover timer-cleanup regressions in with-timeout.test.ts.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 4 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@felipefreitag felipefreitag merged commit 7188941 into main May 11, 2026
7 checks passed
@felipefreitag felipefreitag deleted the fix/spinner-request-timeout-839b branch May 11, 2026 14:10
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.

3 participants