Skip to content

Commit 3bb6963

Browse files
HTTP Module: request.reusedSocket documentation sample code error fix
HTTP Module: request.reusedSocket documentation sample code has a error, their is no agent variable declared in the sample code but that agent variable is used in the request object, which is really confusing for the reader, from where does the agent variable is taken. So, fixed the code by adding the agent variable and taking the http.agent initalization.
1 parent 7e60b5e commit 3bb6963

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

doc/api/http.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ may run into a 'ECONNRESET' error.
11391139

11401140
```mjs
11411141
import http from 'node:http';
1142+
const agent = new http.Agent({ keepAlive: true });
11421143

11431144
// Server has a 5 seconds keep-alive timeout by default
11441145
http
@@ -1160,6 +1161,7 @@ setInterval(() => {
11601161

11611162
```cjs
11621163
const http = require('node:http');
1164+
const agent = new http.Agent({ keepAlive: true });
11631165

11641166
// Server has a 5 seconds keep-alive timeout by default
11651167
http

0 commit comments

Comments
 (0)