Skip to content

Memory leak in node v24.16.0 #63708

@westhecool

Description

@westhecool

Version

v24.16.0

Platform

Linux 9bebfbe9802e 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

The bug can be reproduced using this example test code:

async function main() {
    for (let i = 0; i < 500; i++) {
        let data = Buffer.alloc(1024 * 1024 * 10); // 10MB buffer
        let form = new FormData();
        let blob = new Blob([data], { type: 'application/octet-stream' });
        form.append('file', blob, 'file');
        try {
            let res = await fetch('http://127.0.0.1:10000/', { method: 'POST', body: form, signal: AbortSignal.timeout(100) }); // added timeout of 100ms
        } catch (e) { }
        console.log(i);
    }
    setInterval(() => { }, 1000); // don't exit the script
}

main();

How often does it reproduce? Is there a required condition?

Successfully reproduced every time when tested.

What is the expected behavior? Why is that the expected behavior?

Expected behavior is for the garbage collector to identify the unused buffers and discard them, which is the observed result in node v24.15.0.

What do you see instead?

High memory usage indicating that the buffers are stored in memory permanently.

Additional information

I have also tested this code using packaged Undici version 7.25.0 (the version claimed to be bundled with node v24.16.0) without observing the reported behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions