Describe the bug
Hello👋
First of all, thank you for creating and managing this project.
We understand that Svelte 5 is the recommended version and migrating to Svelte 5 resolves this issue entirely. We are not requesting a fix. However, since SvelteKit 2.x officially supports Svelte 4 compatibility, we are reporting this as a knowledge-sharing contribution so that other users in the same situation are aware of the issue and available workarounds.
with_event(event, () => options.root.render(...)) added to render.js in 2.27.0 triggers Node.js's kResourceStore bug (nodejs/node#53408) when used with Svelte 4.
Svelte 4's component_subscribe keeps unsubscribe callbacks alive until the entire tree is rendered. These long-lived callbacks become async resources inside als.run(), retaining RequestEvent via kResourceStore.
Svelte 5's unsubscribe_stores releases immediately per component, avoiding the issue.
Workarounds: Migrate to Svelte 5, patch als.run() out of with_event, or pin to 2.26.1.
We hope this report will be helpful to teams that are currently updating or considering updating their versions of Svelte and Sveltekit.
Reproduction
Requires Svelte 4 + SvelteKit 2.27.0+ + adapter-node + browser traffic. Take two heap snapshots under load and compare — ServerResponse/RequestEvent accumulate with kResourceStore in the retention path.
Logs
No specific error logs. The issue manifests as linear `heapUsed` growth observable via `process.memoryUsage()`, eventually leading to OOM kill by the container orchestrator (ECS).
Example `heapUsed` growth (production, Major GC post-values):
15:50 36.1MB
16:00 43.5MB
16:10 49.6MB
16:20 52.7MB
16:30 54.6MB
16:40 56.6MB
16:50 58.6MB
17:00 61.0MB
17:10 64.0MB
17:20 65.5MB
17:30 67.2MB
System Info
- Node 22.22.2
- SvelteKit 2.27.0~2.57.1
- Svelte 4.2.20
- adapter-node 5.5.4
Severity
serious, but I can work around it
Additional Information
Related: nodejs/node#53408, #12259, #10204
Describe the bug
Hello👋
First of all, thank you for creating and managing this project.
We understand that Svelte 5 is the recommended version and migrating to Svelte 5 resolves this issue entirely. We are not requesting a fix. However, since SvelteKit 2.x officially supports Svelte 4 compatibility, we are reporting this as a knowledge-sharing contribution so that other users in the same situation are aware of the issue and available workarounds.
with_event(event, () => options.root.render(...))added torender.jsin 2.27.0 triggers Node.js'skResourceStorebug (nodejs/node#53408) when used with Svelte 4.Svelte 4's
component_subscribekeeps unsubscribe callbacks alive until the entire tree is rendered. These long-lived callbacks become async resources insideals.run(), retainingRequestEventviakResourceStore.Svelte 5's
unsubscribe_storesreleases immediately per component, avoiding the issue.Workarounds: Migrate to Svelte 5, patch
als.run()out ofwith_event, or pin to 2.26.1.We hope this report will be helpful to teams that are currently updating or considering updating their versions of Svelte and Sveltekit.
Reproduction
Requires Svelte 4 + SvelteKit 2.27.0+ + adapter-node + browser traffic. Take two heap snapshots under load and compare —
ServerResponse/RequestEventaccumulate withkResourceStorein the retention path.Logs
System Info
Severity
serious, but I can work around it
Additional Information
Related: nodejs/node#53408, #12259, #10204