Skip to content

[BUG] Upgrade Axios to 1.17.0 to fix socket listener leak in long-running Contentful requests #3136

Description

Bug Description

Axios versions before 1.17.0 accumulate socket-level error listeners on reused HTTPS/TLS sockets. Each request registers a new listener on the same socket instead of installing one listener per socket and tracking the active request.

This is most visible in long-running server processes that make repeated requests through the Contentful Management SDK, which internally uses Axios with persistent connections.

Impact:

  • repeated MaxListenersExceededWarning warnings in Node.js
  • listener accumulation on reused TLS sockets
  • retained request references and growing memory usage over time
  • reduced stability of long-lived processes making repeated Contentful API calls

Expected Behavior

Every request adds a new error listener to the reused TLSSocket. After ~11 requests over the same socket Node.js emits a MaxListenersExceededWarning, and listeners (plus their captured request references) remain attached for the socket lifetime.

Error Messages/Logs

MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
11 error listeners added to [TLSSocket]. MaxListeners is 10.

Stack trace includes:

at _addListener (node:events:590:17)
at TLSSocket.addListener (node:events:608:10)
at TLSSocket.Readable.on (node:internal/streams/readable:1135:35)
at RedirectableRequest.handleRequestSocket
(webpack:///../node_modules/axios/lib/adapters/http.js:924:1)
at ClientRequest.eventHandlers.<computed>
(webpack:///../node_modules/follow-redirects/index.js:49:1)

Possible Solution

Axios version is upgraded to 1.17.0 or newer including the socket listener fix

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions