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

MaxListenersExceededWarning: Possible EventEmitter memory leak detected and Regular Expression Denial of Service #349

Closed
1 task done
marck283 opened this issue Oct 4, 2023 · 4 comments

Comments

@marck283
Copy link

marck283 commented Oct 4, 2023

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

Using Node.js version 20.x or later in a project that depends on node-fetch prior to version 3.2.5 results in Node prompting a MaxListenersExceededWarning: Possible EventEmitter memory leak detected warning (as can be seen here). However, node-fetch versions between 3.1.0 and 3.2.10 also suffer from a Regular Expression Denial of Service (as can be seen here). Installing [email protected] seems to solve both problems.

To Reproduce

  1. Initialize a new Node.js project;
  2. install node-fetch prior to version 3.2.10 or packages that depend on node-fetch prior to version 3.2.10.

Code snippets

No response

OS

Windows 11

Node version

Node v20.7.0

Library version

openai v4.11.1

@marck283 marck283 added the bug Something isn't working label Oct 4, 2023
@rattrayalex rattrayalex removed the bug Something isn't working label Oct 4, 2023
@rattrayalex
Copy link
Collaborator

rattrayalex commented Oct 5, 2023

Thanks for the report, we're looking into upgrading.

@rattrayalex
Copy link
Collaborator

We can't upgrade to node-fetch 3.x because it's ESM-only, and this library supports CJS as well.

We're looking into backporting the fix for that issue to the 2.x line.

FWIW, I don't believe the memory leak effects should be very significant, so this warning should be safe to ignore.

@rattrayalex
Copy link
Collaborator

In the meantime, @marck283 you can work around this by installing [email protected] and pass it in to the library:

import nodeFetch from 'node-fetch'
import OpenAI from 'openai'

const client = new OpenAI({ fetch: nodeFetch })

@rattrayalex
Copy link
Collaborator

We don't expect to action this directly, so closing. We are planning to remove our node-fetch dependency before long.

@rattrayalex rattrayalex closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants