@browserbasehq/sdk fails on Node ≥24.17.0 — ERR_STREAM_PREMATURE_CLOSE on every API call (node-fetch@2)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- node.js, typescript
Research direction
Start in _shims/node-runtime.js and inspect how getRuntime().fetch selects the Node HTTP client. Reproduce the failure with the listed Node 24.17.0 sessions call, then verify that API requests, including sessions.create() and sessions.retrieve(), complete successfully using the global fetch path.
Written by the indexing model from the issue text.
Description
Summary
Every Browserbase SDK request throws ERR_STREAM_PREMATURE_CLOSE on Node.js ≥ 24.17.0:
FetchError: Invalid response body while trying to fetch https://api.browserbase.com/v1/sessions: Premature close
code: 'ERR_STREAM_PREMATURE_CLOSE'
type: 'system'
This takes down anything built on the SDK, including Stagehand (BROWSERBASE env): sessions.create() / sessions.retrieve() fail, so stagehand.init() never completes and sessions show ~0s duration in the dashboard.
Root cause
The SDK's node runtime shim (_shims/node-runtime.js, getRuntime().fetch = nf.default) uses node-fetch@2 with agentkeepalive / http.Agent. Node 24.17.0 shipped CVE-2026-48931 "fix response queue poisoning in http.Agent" (+ llhttp 9.4.2), and node-fetch@2's keep-alive response-stream handling can't cope — it reports the body as prematurely closed. node-fetch@2.7.0 is the last v2 release and is effectively unmaintained.
Node's own https and undici (global fetch) are unaffected.
Minimal reproduction (Node 24.17.0)
const Browserbase = require('@browserbasehq/sdk').default;
const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY });
await bb.sessions.list({ status: 'RUNNING' }); // ❌ ERR_STREAM_PREMATURE_CLOSE
Isolation matrix (same host, same key, same endpoint)
| HTTP client | Node 24.16.0 | Node 24.17.0 |
|---|---|---|
| node-fetch@2 (SDK default) | ✅ | ❌ 5/5 ERR_STREAM_PREMATURE_CLOSE |
undici / global fetch |
✅ | ✅ |
core https.request |
✅ | ✅ |
Fix that works (verified)
Have the SDK prefer global fetch (undici) on Node ≥18. Confirmed working end-to-end (create → retrieve → CDP connect) on Node 24.17.0:
new Browserbase({ apiKey, fetch: (...a) => globalThis.fetch(...a) }); // ✅
i.e. getRuntime().fetch should be globalThis.fetch ?? nodeFetch.
Environment
@browserbasehq/sdk2.12.0 (also reproduces conceptually on 2.15.0 — still depends onnode-fetch@^2.6.7)@browserbasehq/stagehand3.4.0 (and 3.6.0, via the same SDK dep)- Node 24.17.0 (works on 24.16.0)
- macOS + Linux (prod)
- Dominant language
- TypeScript
- Stars
- 64
- Forks
- 17
- Avg merge
- 13m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from browserbase/sdk-node
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
browserbase/sdk-node#202 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
browserbase/sdk-node#197 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
browserbase/sdk-node#180 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 66/100
browserbase/sdk-node#218 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
browserbase/sdk-node#214 ·
All issues in browserbase/sdk-node
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·