-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak if add external fetch inside load function #8239
Comments
If I am using |
hmm because of this https://github.com/sveltejs/kit/blob/master/packages/kit/src/exports/node/polyfills.js#L1 even if nodejs support fetch we are using undici implementation. |
The native fetch implementation of node is undici, so there's no difference (except the undici version which is newer through the polyfill) |
okey, I found the root of the leak it's how we tricky use handleFetch here if I return our internal fetch as is, it's working fine, but if by: |
sorry, it's a little bit different: if I use I am hacking now UPDATE: export function create_fetch({ event, options, state, get_cookie_header }) {
return async (info, init) => {
return await fetch(new Request(info, init));
};
} but this has not leaked: export function create_fetch({ event, options, state, get_cookie_header }) {
return async (info, init) => {
return await fetch(info, init);
};
} it means |
okey, hot fix is here nodejs/undici#1824 seems like it's a serious issue, and we must wait for a new release. |
this should be fixed in https://github.com/nodejs/undici/releases/tag/v5.15.0 |
Cool! Now we should update deps for kit. |
Happened in #8459, release soon |
They break it again nodejs/undici#2000 Can we revert undici update? |
sveltejs/kit#8239 sveltejs/kit#9427 Hay que vigilar si se resuelve el problema de undici
Describe the bug
Very fast memory leak, basically we hold all response strings and all fetch data from remote servers. It seems like because we have circular links for abort callback inside node-fetch(it uses WeakRef and etc, but it's not working).
Reproduction
Create a new test project from the starter and add into +layout.server.js the load function:
it's can be any other external (outside sveltekit) request. And run
wrk
orab
over any page.You can build it for the node adapter and run it or it works even in dev.
I am use next command to debug:
ORIGIN=http://localhost:3000 /usr/bin/node --es-module-specifier-resolution=node --max_old_space_size=200 --inspect --expose-gc build/
Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
I found this after deploying my project to production... now I am in a really bad situation because nodejs process is restarted each 30mins.
The text was updated successfully, but these errors were encountered: