sveltejs / sveltejs/kit

query.live connections are only released by garbage collection

Open Beginner friendly
#16,422 12 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

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:

  1. Navigating to Page A opens 5 connections
  2. Navigating to Page B adds an extra connection
  3. Clicking on the link to Page C does NOTHING
  4. Eventually (around the 25s mark) the connections get garbage collected and only then does page C load.
  5. 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.6
Severity

serious, but I can work around it

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/kit/src/runtime/client/remote-functions/query-live/proxy.js and compare the LiveQueryProxy with the public destroy() method in instance.svelte.js. Use the linked reproduction to verify that app code can close live queries and that navigation no longer leaves zombie streams; automatic cleanup for unmounted components is an additional consideration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.