Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary web-streams-polyfill polluting global namespace #613

Open
1 task done
jacoblee93 opened this issue Jan 8, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@jacoblee93
Copy link

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

  • This is an issue with the Node library

Describe the bug

The web-streams-polyfill package has a TypeScript bug where it pollutes the global namespace and misdefines [Symbol.asyncIterator] as a property rather than a method:

https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/dist/types/ts3.6/polyfill.d.ts#L26

vs.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator/@@asyncIterator

This causes subtle typing bugs downstream. Furthermore, ReadableStream is now supported in the LTS version of Node, so the polyfill is no longer necessary:

https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream

To Reproduce

Create an interface that extends both ReadableStream and AsyncGenerator after importing the SDK:

import OpenAI from "openai";

interface IterableReadableStreamInterface<T> extends ReadableStream<T>, AsyncGenerator<T> {}

Code snippets

No response

OS

macOS

Node version

18

Library version

4.24.1

@jacoblee93
Copy link
Author

I will also file a bug on web-streams-polyfill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant