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

Function remoteClose

test/parallel/test-http-agent-keepalive.js:84–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82}
83
84function remoteClose() {
85 // Mock remote server close the socket
86 const req = get('/remote_close', common.mustCall((res) => {
87 assert.strictEqual(req.reusedSocket, true);
88 assert.strictEqual(res.statusCode, 200);
89 res.on('data', checkDataAndSockets);
90 res.on('end', common.mustCall(() => {
91 assert.strictEqual(agent.sockets[name].length, 1);
92 assert.strictEqual(agent.freeSockets[name], undefined);
93 process.nextTick(common.mustCall(() => {
94 assert.strictEqual(agent.sockets[name], undefined);
95 assert.strictEqual(agent.freeSockets[name].length, 1);
96 assert.strictEqual(agent.totalSocketCount, 1);
97 // Waiting remote server close the socket
98 setTimeout(common.mustCall(() => {
99 assert.strictEqual(agent.sockets[name], undefined);
100 assert.strictEqual(agent.freeSockets[name], undefined);
101 assert.strictEqual(agent.totalSocketCount, 0);
102 remoteError();
103 }), common.platformTimeout(200));
104 }));
105 }));
106 }));
107}
108
109function remoteError() {
110 // Remote server will destroy the socket

Callers 1

secondFunction · 0.85

Calls 4

remoteErrorFunction · 0.85
getFunction · 0.70
setTimeoutFunction · 0.50
onMethod · 0.45

Tested by

no test coverage detected