openai / openai-node

Official JavaScript / TypeScript library for the OpenAI API
https://www.npmjs.com/package/openai
Apache License 2.0
7.93k stars 863 forks source link

Leftover from polyfill removal: web-streams-polyfill #1083

Closed tobias-schwerdtfeger closed 1 month ago

tobias-schwerdtfeger commented 1 month ago

Confirm this is a Node library issue and not an underlying OpenAI API issue

Describe the bug

Just updated to the latest version and encountered this during a build:

node_modules/openai/_shims/node-types.d.ts:10:32 - error TS2307: Cannot find module 'web-streams-polyfill' or its corresponding type declarations.

10 export { ReadableStream } from 'web-streams-polyfill';
                                  ~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/openai/_shims/node-types.d.ts:10

I guess it's a leftover from #954 and should be export { ReadableStream } from 'node:stream/web';

To Reproduce


Code snippets

No response

OS

macOS

Node version

Node v20.15.1

Library version

openai v4.62.0

RobertCraigie commented 1 month ago

Thanks for the report, could you share your tsconfig.json / package.json? I'm not sure how we didn't catch this earlier

tobias-schwerdtfeger commented 1 month ago

Here's the package.json:

{
  "name": "...",
  "scripts": {
    "build": "tsc -p ./tsconfig.json && tsc-alias -p ./tsconfig.json",
  },
  "engines": {
    "node": "20"
  },
  "type": "module",
  "exports": "./lib/index.js",
  "main": "lib/index.js",
  "dependencies": {
    "openai": "4.62.0",
    "firebase-admin": "^12.1.0",
    "firebase-functions": "^5.0.0",
    "async": "3.2.5",
    "async-mutex": "0.5.0",
    "zod": "3.23.8",
    "patch-package": "8.0.0"
  },
  "devDependencies": {
    "@trivago/prettier-plugin-sort-imports": "4.3.0",
    "@types/async": "3.2.24",
    "@types/jest": "29.5.12",
    "@typescript-eslint/eslint-plugin": "7.6.0",
    "@typescript-eslint/parser": "7.6.0",
    "concurrently": "8.2.2",
    "eslint": "8.57.0",
    "eslint-config-google": "0.14.0",
    "eslint-config-prettier": "9.1.0",
    "eslint-plugin-import": "2.29.1",
    "prettier": "3.2.5",
    "ts-jest": "29.1.2",
    "tsc-alias": "1.8.8",
    "typescript": "5.4.5"
  },
  "private": true
}

And the tsconfig.json:

{
  "compilerOptions": {
    "module": "nodenext",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2022",
    "esModuleInterop": true,
    "allowJs": true,
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "compileOnSave": true,
  "include": ["src"]
}
RobertCraigie commented 1 month ago

Thanks! Will be shipping a fix for this shortly

RobertCraigie commented 1 month ago

@tobias-schwerdtfeger this should be fixed in v4.62.1!