Node: Memory leak with http2 write()

Created on 16 Jan 2018  路  6Comments  路  Source: nodejs/node

  • Version: 9.4.0
  • Platform: Windows 10 64-bit
  • Subsystem: http2

If you use req.write("") in http2, with an empty string, the memory gets higher and higher without end. Memory leak?

        req.write("", () => {
            console.log("dun knoe");
        });

image

Note: Re-creation script is a few posts down this one

confirmed-bug http2

Most helpful comment

Here, I have created a simplified script to re-create the issue:

save it as a test.js file, and type node test.js:

const http2 = require("http2");

const client = http2.connect(`https://www.google.com`);

const req = client.request({
    ":method": "POST",
    ":path": `/v2/events`,
    authorization: `Bearer test-here`,
    "content-type": "multipart/form-data; boundary=dench-gang",
});

req.on("response", (headers, flags) => {
    for (const name in headers) {
        console.log(`${name}: ${headers[name]}`);
    }
});

req.write("");

req.end();

All 6 comments

Entirely possible. Will investigate.

ping /cc @addaleax

Evaluating test-http2-zero-length-write.js is not revealing any leaks when using the lower level API. @dolanmiu ... can I ask you to please put together a more complete test case that demonstrates the issue consistently that I can try. Thank you.

the memory gets higher and higher without end. Memory leak?

How are you calling .write()? If you do so in a synchronous loop, this is more or less expected, because the streams implementation needs to keep track of each callback that you passed to write().

Here, I have created a simplified script to re-create the issue:

save it as a test.js file, and type node test.js:

const http2 = require("http2");

const client = http2.connect(`https://www.google.com`);

const req = client.request({
    ":method": "POST",
    ":path": `/v2/events`,
    authorization: `Bearer test-here`,
    "content-type": "multipart/form-data; boundary=dench-gang",
});

req.on("response", (headers, flags) => {
    for (const name in headers) {
        console.log(`${name}: ${headers[name]}`);
    }
});

req.write("");

req.end();

@addaleax no loop from what I can see, unless I am missing something

I think I've found the key. I'll work on it.

Was this page helpful?
0 / 5 - 0 ratings