Repository navigation
Closed
Description
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
httpBatchStreamLinkcall adds anabortlistener to the caller'sAbortSignaland never removes it. - Reusing one signal for many calls leaves one listener per call. Each holds the call's internal
AbortControlleruntil the signal itself is collected. - fix(client): release completed HTTP request abort listeners #7606 fixed the same leak in
httpLinkandhttpBatchLink, but not here. - Expected: no listeners left on the caller's signal once the calls settle.
Link to reproduction
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
- A query that returns an async iterable resolves while its response is still streaming. So releasing the listener in the observable teardown, as fix(client): release completed HTTP request abort listeners #7606 does, would stop the caller's signal from cancelling the stream. The listener has to stay until the response ends.
👨👧👦 Contributing
- 🙋♂️ Yes, I'd be down to file a PR fixing this bug!
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(client): release httpBatchStreamLink abort listeners when the res…
github-actions commentedon Nov 18, 2026
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.