Skip to content
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

fetch + signal memory leak #16487

Closed
exe-dealer opened this issue Oct 30, 2022 · 4 comments · Fixed by #21087
Closed

fetch + signal memory leak #16487

exe-dealer opened this issue Oct 30, 2022 · 4 comments · Fixed by #21087
Assignees
Labels
bug Something isn't working correctly

Comments

@exe-dealer
Copy link

exe-dealer commented Oct 30, 2022

deno v1.27.0

const { signal } = new AbortController();
const kAbortAlgos = Object.getOwnPropertySymbols(signal).find(s => String(s) == 'Symbol([[abortAlgos]])');

console.log('abortAlgos size before', signal[kAbortAlgos]?.size);
for (let i = 0; i < 100; i++) {
  const resp = await fetch('data:,', { signal });
  await resp.arrayBuffer();
}
console.log('abortAlgos size after', signal[kAbortAlgos].size);

stdout:

abortAlgos size before undefined
abortAlgos size after 100
@exe-dealer
Copy link
Author

parentSignal[add](() =>
followingSignal[signalAbort](parentSignal.reason)

this callback is added to signal but never removed. If signal lifetime is the same as application lifetime, then memory usage grows until deno crash.

@bartlomieju bartlomieju added the bug Something isn't working correctly label Nov 1, 2022
@nktpro
Copy link

nktpro commented May 5, 2023

I could also confirm this issue still persists as of the latest 1.33.2 release.

@lucab
Copy link
Contributor

lucab commented Nov 6, 2023

The fetch spec related to this has been updated by whatwg/fetch#1646 in the meanwhile, so the proper fix for this will likely follow after #18944 is done.

@lucab
Copy link
Contributor

lucab commented Nov 13, 2023

Fixed as part of #21087.

@lucab lucab closed this as completed Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants