Skip to content
This repository was archived by the owner on Jun 14, 2026. It is now read-only.

Commit fac47ee

Browse files
committed
fix(openai): prefer native fetch over cross-fetch
1 parent 75706cf commit fac47ee

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/openai/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import fetch from 'cross-fetch';
1+
import crossFetch from 'cross-fetch';
2+
3+
// Prefer the runtime's native fetch when available. cross-fetch's Node ponyfill
4+
// returns a node-fetch Response whose body is a Node Readable stream — that
5+
// lacks `.getReader()`, which this adapter needs for SSE parsing. Native fetch
6+
// in Node 18+ / browsers / Bun returns a Web ReadableStream.
7+
const fetch: typeof globalThis.fetch =
8+
typeof globalThis.fetch === 'function' ? globalThis.fetch.bind(globalThis) : crossFetch;
29

310
type JsonPrimitive = string | number | boolean | null;
411
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];

0 commit comments

Comments
 (0)