Skip to content

SDK client times out after exactly 5 minutes on Node.js when using session.prompt() #15555

Closed as not planned

Description

@yuvalyacoby

Description

When using @opencode-ai/sdk on Node.js 22 (not Bun), any session.prompt() call that takes longer than 5 minutes fails with:

HeadersTimeoutError: Headers Timeout Error
at FastTimer.onParserTimeout [as _onTimeout] (node:internal/deps/undici/undici:7529:32)
at Timeout.onTick [as _onTimeout] (node:internal/deps/undici/undici:692:17)

This is undici's default headersTimeout of 300,000ms (5 minutes) on Node.js's built-in fetch().

We're using the SDK to orchestrate multi-step agent workflows (fix, lint, review, commit). Short-running prompts (< 5 min)
succeed. Long-running ones (e.g., lint verification via a subagent) fail at exactly 5 minutes every time.

The SDK already has a workaround in packages/sdk/js/src/v2/client.ts that sets req.timeout = false before calling fetch(). It seems this has no effect...

Steps to reproduce:

  1. Use @opencode-ai/sdk on Node.js 22 (not Bun)
  2. Call client.session.prompt() with a prompt that triggers agent work lasting > 5 minutes
  3. The call fails at exactly 5 minutes with HeadersTimeoutError

OpenCode version: SDK @opencode-ai/sdk v1.1.4

Operating System: Linux (Node.js 22 Alpine container)

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 1, 2026
  2. chengbofar commented on Mar 4, 2026

    @chengbofar

    I have the same issue

  3. zhangzhi9410 commented on Mar 13, 2026

    @zhangzhi9410

    I have the same issue

  4. gf9276 commented on Mar 18, 2026

    @gf9276

    I have the same question. Is opencode listening to input, causing the program to hang?

  5. omriel1 commented on Apr 13, 2026

    @omriel1

    Hi, I have the same issue. Do we have a proposed solution?

  6. mwlik commented on Apr 28, 2026

    @mwlik

    (@chengbofar, @zhangzhi9410, @gf9276, @omriel1) node's fetch seems to have some kind of 300s timeout (nodejs/node#46375), the quick fix for me was this (stackoverflow):

    import { setGlobalDispatcher, Agent } from "undici"
    ...
    setGlobalDispatcher(new Agent({ connectTimeout: 3600_000, headersTimeout: 3600_000, bodyTimeout: 3600_000 }))
    ...
  7. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  8. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions