Node library returns ECONNRESET, while curl works

Hi. I’ve a weird issue, when I use OpenAI Node library its internal fetch returns ECONNRESET, while from the very same machine if I run a curl request works correctly (returning an API error or quota exceeded).

  cause: FetchError: request to https://api.openai.com/v1/audio/transcriptions failed, reason: read ECONNRESET
      at ClientRequest.<anonymous> (/Users/maxxer/work/origlio/node_modules/node-fetch/lib/index.js:1501:11)
      at ClientRequest.emit (node:events:519:28)
      at TLSSocket.socketErrorListener (node:_http_client:495:9)
      at TLSSocket.emit (node:events:531:35)
      at emitErrorNT (node:internal/streams/destroy:169:8)
      at emitErrorCloseNT (node:internal/streams/destroy:128:3)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    type: 'system',
    errno: 'ECONNRESET',
    code: 'ECONNRESET'

What can cause this behavior?
thanks

2 Likes

I dunno what causes this particular problem, but I feel like the OpenAI api libs don’t add much value.

We use axios because we found the libs to occasionally either be unreliable or behind the actual api capabilities.

1 Like

Oh sh**, I changed my Axios requests to use the lib, as it seemed simpler :rofl:

Weird the lib works fine with a third party openai-compatible provider (where indeed I do have quota available).

1 Like

OpenAI package is using node-fetch to do requests to their API. The error econreset is related to that package. So use other packages as Axios, needlejs… to make requests instead of their official package

We get a LOT of errors calling the OpenAI APIs using their npm package – many variants including ECONNRESET. We eventually added a retry layer in our code with exponential backoffs and this has reduced errors by about 98%. However, our experience is that some days the APIs just work terribly – 25-50% errors. I keep saying to my colleagues, “How can these guys be running an API business? They might not be for long if they keep this up.” Then the next day it is back to normal. Then a week later, the same thing again. Reliability is terrible.

1 Like