gateway icon indicating copy to clipboard operation
gateway copied to clipboard

Unhandled Promise Rejections

Open jpulec opened this issue 7 months ago • 2 comments
trafficstars

What Happened?

Seeing some unhandledPromiseRejections get thrown out the top, in what appears to be cases where portkey isn't fully consuming the response. It appears to be similar to this undici issue

Unhandled Rejection: TypeError: terminated
    at Fetch.onAborted (node:internal/deps/undici/undici:11124:53)
    at Fetch.emit (node:events:518:28)
    at Fetch.terminate (node:internal/deps/undici/undici:10282:14)
    at Object.onError (node:internal/deps/undici/undici:11245:38)
    at Request.onError (node:internal/deps/undici/undici:2094:31)
    at Object.errorRequest (node:internal/deps/undici/undici:1591:17)
    at TLSSocket.<anonymous> (node:internal/deps/undici/undici:6319:16)
    at TLSSocket.emit (node:events:530:35)
    at node:net:351:12
    at TCP.done (node:_tls_wrap:650:7) {
  [cause]: SocketError: other side closed
      at TLSSocket.<anonymous> (node:internal/deps/undici/undici:6294:28)
      at TLSSocket.emit (node:events:530:35)
      at endReadableNT (node:internal/streams/readable:1698:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: '169.254.100.6',
      localPort: 46288,
      remoteAddress: '162.159.140.245',
      remotePort: 443,
      remoteFamily: 'IPv4',
      timeout: undefined,
      bytesWritten: 36928,
      bytesRead: 58950
    }
  }
}
Node.js process exited with exit status: 128. The logs above can help with debugging the issue.

What Should Have Happened?

Process shouldn't have crashed.

Relevant Code Snippet

No response

Your Twitter/LinkedIn

No response

jpulec avatar Apr 04 '25 18:04 jpulec

Hi @jpulec , thanks for undici issue link! We will take a look at it.

VisargD avatar Apr 09 '25 18:04 VisargD

we can capture and ignore unhandled process rejections with, I think we should add this to the gateway, especially useful for self deployed instances

process.on('uncaughtException', (err) => {
  console.error('Unhandled exception', err);
});

process.on('unhandledRejection', (err) => {
  console.error('Unhandled rejection', err);
});

narengogi avatar Jul 09 '25 07:07 narengogi