AbortSignal.any() causes memory leak
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.4k
- Ø Merge
- 4 T. 3 Std.
- Gemergte PRs (30 T.)
- 272
Beschreibung
Version
v22.6.0
Platform
Microsoft Windows NT 10.0.22631.0 x64
Linux ****** 4.4.0-22621-Microsoft #3672-Microsoft Fri Jan 01 08:00:00 PST 2016 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
https://nodejs.org/api/globals.html#class-abortsignal
What steps will reproduce the bug?
Run this and watch memory usage.
const formatMemoryUsage = (data) => `${Math.round(data / 1024 / 1024 * 100) / 100} MB`;
let memoryData = process.memoryUsage();
console.log('Mem before loop', formatMemoryUsage(memoryData.rss));
for (let i = 0; true; i++) {
const abortController = new AbortController();
const signal = abortController.signal;
const composedSignal = AbortSignal.any([signal]);
if (i === 1000000) {
break;
}
}
memoryData = process.memoryUsage();
console.log('Mem after 1 million iteration', formatMemoryUsage(memoryData.rss));
This is what I get on my local machine
How often does it reproduce? Is there a required condition?
Always reproducible as far as I can tell
What is the expected behavior? Why is that the expected behavior?
Memory post loop execution should be fairly equivalent to the first log but somehow the const composedSignal = AbortSignal.any([signal]); does not get cleaned up from memory, I would expect this to get cleaned properly or if this is the intended behavior to have a clear warning in the documentation.
What do you see instead?
We see a memory leak that will eventually lead to an out of memory error.
Additional information
This has been tested on Node 22.6 on different machine and both Windows + Unix versions. Happy to provide more details if needed
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit dem im Issue beschriebenen Einstiegspunkt AbortSignal.any() und führen Sie die bereitgestellte JavaScript-Reproduktion unter Node.js aus, um das Speicherwachstum zu bestätigen. Verfolgen Sie, wie das zusammengesetzte Signal sein Eingangssignal beibehält, und bestimmen Sie, wann diese Referenzen freigegeben werden sollten. Die Aufgabe ist erledigt, wenn die wiederholte Erstellung von Kompositionen mit einem einzelnen Signal kein anhaltendes Speicherwachstum mehr verursacht und die Reproduktion zur Überprüfung des Verhaltens verwendet wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100