Skip to content

Memory leak in Http2SessionManager's verify step #1617

@timostamm

Description

@timostamm

Describe the bug

See the PR description of #1616

To Reproduce

The issue can be reproduced with the example in this repository, by modifying packages/example/src/client.ts:

import {Http2SessionManager} from "@connectrpc/connect-node";

const m = new Http2SessionManager("https://localhost:8443", {}, {
  rejectUnauthorized: false,
});
if (await m.connect() != "idle") {
  throw new Error();
}
if ((m.s.t !== "ready")) {
  throw new Error();
}
for (;;) {
  console.log("verify...");
  if (await m.s.verify() !== true) {
    throw new Error();
  }
  await new Promise(resolve => setTimeout(resolve, 250));
}
$ npx tsx --trace-warnings src/client.ts
verify...
verify...
verify...
verify...
verify...
verify...
verify...
verify...
verify...
verify...
(node:47224) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [ClientHttp2Session]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
    at genericNodeError (node:internal/errors:985:15)
    at wrappedFn (node:internal/errors:539:14)
    at _addListener (node:events:581:17)
    at ClientHttp2Session.addListener (node:events:599:10)
    at ClientHttp2Session.once (node:events:643:8)
    at file:///Users/ts/Downloads/connect-es-ttyniwa/packages/connect-node/dist/esm/http2-session-manager.js:385:22
    at new Promise (<anonymous>)
    at Object.verify (file:///Users/ts/Downloads/connect-es-ttyniwa/packages/connect-node/dist/esm/http2-session-manager.js:379:20)
    at <anonymous> (/Users/ts/Downloads/connect-es-ttyniwa/packages/example/src/t.ts:26:17)
verify...

Environment (please complete the following information):

  • @connectrpc/connect-node version: 2.1.0
  • Node.js version: v24.5.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