MCPcopy Create free account
hub / github.com/nodejs/node / main

Function main

test/parallel/test-http-client-leaky-with-double-response.js:22–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22async function main() {
23 const server = await createServer();
24 const req = http.get({
25 port: server.address().port,
26 }, common.mustCall((res) => {
27 const chunks = [];
28 res.on('data', common.mustCallAtLeast((c) => chunks.push(c), 1));
29 res.on('end', common.mustCall(() => {
30 const body = Buffer.concat(chunks).toString('utf8');
31 const data = JSON.parse(body);
32 assert.strictEqual(data.hello, 'world');
33 }));
34 }));
35 const timer = setInterval(global.gc, 300);
36 onGC(req, {
37 ongc: common.mustCall(() => {
38 clearInterval(timer);
39 server.close();
40 })
41 });
42}
43
44main();

Calls 12

onGCFunction · 0.85
clearIntervalFunction · 0.85
concatMethod · 0.80
createServerFunction · 0.70
getMethod · 0.65
addressMethod · 0.65
parseMethod · 0.65
closeMethod · 0.65
setIntervalFunction · 0.50
onMethod · 0.45
pushMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected