Skip to content

OpenAI client prevents process from gracefully terminating #1311

@punkpeye

Description

@punkpeye

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

When using OpenAI client to stream completions, the process fails to shutdown gracefully.

To Reproduce

Stream and attempt to gracefully shutdown.

Active handles show instances of agentkeepalive, which is coming from OpenAI SDK.

{
  resource: {
    _parent: '[Object: TCP]',
    _parentWrap: null,
    _secureContext: '[Object: SecureContext]',
    onerror: '[Function: onerror]',
    onhandshakedone: '[Function: ]',
    onhandshakestart: '[Function: noop]',
    onkeylog: '[Function: onkeylog]',
    onnewsession: '[Function: onnewsessionclient]',
    onocspresponse: '[Function: onocspresponse]',
    reading: true
  },
  stacks: [
    'node:internal/async_hooks:202:43 [emitInitNative]',
    'node:_tls_wrap:699:24 [TLSSocket._wrapHandle]',
    'node:_tls_wrap:570:18 [TLSSocket]',
    'node:_tls_wrap:1766:19 [connect]',
    'node:https:173:22 [createConnection]',
    '/Users/frank/Developer/glama/node_modules/.pnpm/agentkeepalive@4.6.0/node_modules/agentkeepalive/lib/https_agent.js:29:49 [createConnection]',
    'node:_http_agent:324:26 [createSocket]',
    'node:_http_agent:276:10 [addRequest]',
    'node:_http_client:347:16 [ClientRequest]'
  ],
  type: 'TLSWRAP'
},

Code snippets

OS

macOS

Node version

22

Library version

4.83.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions