Skip to content

Commit

Permalink
fix: remove node-fetch from runtime bundle (#51)
Browse files Browse the repository at this point in the history
- fixes #50 (for
real this time)
  • Loading branch information
ctjlewis committed Jun 23, 2023
2 parents d8fdf04 + 73a9edc commit 89b00cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "openai-streams",
"description": "Tools for working with OpenAI streams in Node.js and TypeScript.",
"homepage": "https://github.com/SpellcraftAI/openai-streams",
"version": "5.22.0",
"version": "5.22.1-canary.0",
"license": "MIT",
"platform": "node",
"engines": {
Expand Down Expand Up @@ -47,13 +47,13 @@
"ava": "^5.2.0",
"dotenv": "^16.0.3",
"eslint": "^8.41.0",
"node-fetch": "^3.3.1",
"openai": "^3.3.0",
"typedoc": "^0.24.7",
"typescript": "^5.0.4"
},
"dependencies": {
"eventsource-parser": "^1.0.0",
"node-fetch": "^3.3.1",
"yield-stream": "^3.0.0"
},
"keywords": [
Expand Down
17 changes: 8 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/lib/backoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export interface BackoffOptions {
export const fetchWithBackoff = async (
input: RequestInfo & NodeFetchRequestInfo,
init?: RequestInit & NodeFetchRequestInit,
fetch?: Fetch,
fetch: Fetch = globalThis.fetch,
{ delay, maxRetries }: BackoffOptions = {
delay: 500,
maxRetries: 7
}
) => {
if (!fetch) {
const { default: nodeFetch } = await import("node-fetch");
fetch = nodeFetch;
throw new Error("No fetch implementation found.");
}

for (let i = 0; i <= maxRetries; i++) {
Expand Down

1 comment on commit 89b00cb

@vercel
Copy link

@vercel vercel bot commented on 89b00cb Jun 23, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.