query.live connections are only released by garbage collection
Describe the bug
A query.live connection cannot be closed from app code: the proxy exposes reconnect() but no disconnect()/close().
This presents an issue, because browsers cap HTTP/1.1 at ~6 connections per origin. Dev servers are also usually using HTTP/1.1 and hence limited to HTTP/1.1, so it's relatively easy to reproduce.
I have one page with 5 live queries and another with 1 — navigating through both leaves 6 zombie streams from unmounted components, and the SPA deadlocks until a full refresh or the eventual garbage collection.
The fix already exists: the inner LiveQuery has a public destroy() but it's not exposed through the LiveQueryProxy.
Adding it there would allow us to manually close live queries.
destroy() {
return this.#get_cached_query().destroy();
}Additionally, if you can accelerate the connection cleanup automatically when components are unmounted - even better.
Reproduction
https://github.com/itay-grudev/svelte-query.live-repro
In the screen cast below, you can see how:
- Navigating to Page A opens 5 connections
- Navigating to Page B adds an extra connection
- Clicking on the link to Page C does NOTHING
- Eventually (around the 25s mark) the connections get garbage collected and only then does page C load.
- Notice how on Page A the tickers are reset, because navigating to it opens brand new connections.
https://github.com/user-attachments/assets/b3b570f0-1eb0-4efb-989b-82b8034ae903
Logs
System Info
System:
OS: Linux 7.1 Fedora Linux 44 (Workstation Edition)
CPU: (32) x64 AMD Ryzen 9 7950X3D 16-Core Processor
Memory: 22.15 GB / 61.94 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 24.10.0 - /run/user/1000/fnm_multishells/2630127_1784428707317/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 11.6.1 - /run/user/1000/fnm_multishells/2630127_1784428707317/bin/npm
pnpm: 10.33.0 - /usr/bin/pnpm
Browsers:
Firefox: 152.0.4
Firefox Developer Edition: 152.0.4
npmPackages:
@sveltejs/adapter-auto: ^7.0.0 => 7.0.1
@sveltejs/kit: ^2.48.5 => 2.70.0
@sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.4
svelte: ^5.43.8 => 5.56.6
vite: ^7.2.2 => 7.3.6Severity
serious, but I can work around it
Additional Information
No response
Source: sveltejs/kit