adapter-node upgrade lead to Memory Leak on SSR
Describe the bug
We are observing memory leak in our code after upgrading to svelte kit 2. On further investigation found out the leak is coming from the fetch function (part of event object and not global fetch) used in load function of page.ts. To validate the fact we used global fetch and saw no memory leak.
Reproduction
- Create new svelte-kit project using this command => npm create svelte@latest my-app
- call an api in load function in one of the page.ts using load fetch and not global fetch
Logs
N.A
System Info
System:
OS: macOS 12.1
CPU: (10) arm64 Apple M1 Pro
Memory: 81.33 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
pnpm: 7.30.0 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 125.0.6422.76
Safari: 15.2
npmPackages:
@bulatdashiev/svelte-slider: 1.0.3 => 1.0.3
@lottiefiles/svelte-lottie-player: ^0.3.1 => 0.3.1
@playwright/test: 1.28.1 => 1.28.1
@sveltejs/adapter-node: 2.1.2 => 2.1.2
@sveltejs/kit: 2.5.0 => 2.5.0
@sveltejs/vite-plugin-svelte: 3.0.2 => 3.0.2
@typescript-eslint/eslint-plugin: 5.61.0 => 5.61.0
@typescript-eslint/parser: 5.61.0 => 5.61.0
@vite-pwa/sveltekit: 0.2.7 => 0.2.7
autoprefixer: 10.4.14 => 10.4.14
cache-manager: ^5.4.0 => 5.4.0
cookie-es: 0.5.0 => 0.5.0
daisyui: 2.51.4 => 2.51.4
date-fns: 2.30.0 => 2.30.0
eslint: 8.44.0 => 8.44.0
eslint-config-prettier: 8.8.0 => 8.8.0
eslint-plugin-import: ^2.29.1 => 2.29.1
eslint-plugin-simple-import-sort: ^12.0.0 => 12.1.0
eslint-plugin-svelte3: 4.0.0 => 4.0.0
fflate: 0.7.4 => 0.7.4
fluent-svelte: ^1.6.0 => 1.6.0
hls.js: ^1.5.7 => 1.5.7
husky: 8.0.3 => 8.0.3
jsonwebtoken: 9.0.0 => 9.0.0
kolorist: ^1.8.0 => 1.8.0
lodash.merge: 4.6.2 => 4.6.2
ohash: ^1.1.3 => 1.1.3
postcss: 8.4.35 => 8.4.35
prettier: 2.8.8 => 2.8.8
prettier-plugin-svelte: 2.10.0 => 2.10.0
prettier-plugin-tailwindcss: 0.3.0 => 0.3.0
rollup-plugin-visualizer: 5.9.2 => 5.9.2
svelte: 4.2.1 => 4.2.1
svelte-check: 3.5.2 => 3.5.2
tailwindcss: 3.3.3 => 3.3.3
tslib: 2.6.0 => 2.6.0
typescript: 5.2.2 => 5.2.2
ua-parser-js: ^1.0.35 => 1.0.35
vite: 5.0.12 => 5.0.12
vite-plugin-pwa: 0.16.4 => 0.16.4
vitest: 1.2.2 => 1.2.2
Severity
annoyance
Additional Information
No response
On Further investigation found out the "@sveltejs/adapter-node" package had the leak, downgraded the version to "1.2.4"
Which version was the adapter node package prior to downgrading? Did you try updating to the latest LTS version of Node.js (20)? (If that leak stems from undici which comes bundled with node)
@sveltejs/adapter-node: 2.1.2 was the version before downgrading. Current Node Version is 18.3 will try with above mentioned version and check on the leak
This issue has been dead for a while. If you can still reproduce this issue, please:
-
npx sv create my-repro -
git init && git add --all && git commit -m "Initial commit" - Add the code that minimally illustrates your issue
-
git add --all && git commit -m "Reproduce issue" - Create a repository on GutHub and upload your code
- Open a new issue with the reproduction