Skip to content

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

Open
bukinoshita wants to merge 6 commits intomainfrom
fix/spinner-request-timeout-839b
Open

fix: add 30s request timeout to withSpinner to prevent hanging CLI commands#237
bukinoshita wants to merge 6 commits intomainfrom
fix/spinner-request-timeout-839b

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

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
Copy link
Copy Markdown
Contributor

cubic-dev-ai bot commented Apr 13, 2026

@cubic-dev-ai can you review?

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

Copy link
Copy Markdown
Contributor

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

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
Copy link
Copy Markdown
Contributor

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

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
try {
for (let attempt = 0; ; attempt++) {
const { data, error, headers } = await call();
const { data, error, headers } = await withTimeout(
Copy link
Copy Markdown
Contributor

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

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 3 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.
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