Skip to content

bug: httpBatchStreamLink leaves an abort listener on the caller's signal for every call #8055

Closed

Description

@taham8875

Provide environment information

  System:
    OS: Linux 7.0 Ubuntu 24.04.5 LTS 24.04.5 LTS (Noble Numbat)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
    Memory: 10.67 GB / 31.01 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 24.13.0 - /home/taha/.nvm/versions/node/v24.13.0/bin/node
    Yarn: 4.18.1 - /home/taha/.local/share/vite-plus/bin/yarn
    npm: 11.6.2 - /home/taha/.nvm/versions/node/v24.13.0/bin/npm
    pnpm: 10.28.0 - /usr/local/bin/pnpm
    bun: 1.4.2 - /home/taha/.bun/bin/bun
  Browsers:
    Chrome: 155.0.8059.84
    Firefox: 158.0.1
    Firefox Developer Edition: 158.0.1
  npmPackages:
    @trpc/client: ^11.28.2 => 11.28.2 
    @trpc/server: ^11.28.2 => 11.28.2

Describe the bug

  • Each httpBatchStreamLink call adds an abort listener to the caller's AbortSignal and never removes it.
  • Reusing one signal for many calls leaves one listener per call. Each holds the call's internal AbortController until the signal itself is collected.
  • fix(client): release completed HTTP request abort listeners #7606 fixed the same leak in httpLink and httpBatchLink, but not here.
  • Expected: no listeners left on the caller's signal once the calls settle.

Link to reproduction

https://github.com/taham8875/trpc/blob/c5d2aa816fb387dc1b211f40172c4bbf76669f02/packages/client/src/links/httpAbortCleanup.test.ts#L242-L292

To reproduce

import { getEventListeners } from 'node:events';
import { createTRPCClient, httpBatchStreamLink } from '@trpc/client';
import { initTRPC } from '@trpc/server';
import { createHTTPServer } from '@trpc/server/adapters/standalone';

const t = initTRPC.create();
const router = t.router({
  value: t.procedure.query(() => 'ok'),
});

const server = createHTTPServer({ router }).listen(3999);

const client = createTRPCClient({
  links: [httpBatchStreamLink({ url: 'http://localhost:3999' })],
});

const controller = new AbortController();
for (let i = 0; i < 5; i++) {
  await client.value.query(undefined, { signal: controller.signal });
}

console.log(getEventListeners(controller.signal, 'abort').length); // 5, expected 0
server.close();

With httpBatchLink in place of httpBatchStreamLink, the same script prints 0.

Additional information

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Activity

  1. added a commit that references this issue on Nov 17, 2026
    95f0b5c
  2. github-actions commented on Nov 18, 2026

    @github-actions
    Contributor

    This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you.

  3. locked as resolved and limited conversation to collaborators on Nov 18, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions