Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Oct 26, 2020
1 parent 5869e45 commit 1d3448a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ Options:
Default: `null`.
* `signal: AbortController|EventEmitter|Null`
Default: `null`.
- `headersTimeout: Number`, the amount of time the parser will wait to receive the complete
HTTP headers.
Default: `30e3` milliseconds (30s).
- `headersTimeout: Number`, the timeout after which a request will time out, in
milliseconds. Monitors time between receiving a complete headers.
Use `0` to disable it entirely. Default: `30e3` milliseconds (30s).
- `bodyTimeout: Number`, the timeout after which a request will time out, in
milliseconds. Monitors time between receiving a body data.
Use `0` to disable it entirely. Default: `30e3` milliseconds (30s).
Expand Down
13 changes: 6 additions & 7 deletions lib/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const insecureHTTPParser = process.execArgv.includes('--insecure-http-parser')
class Client extends EventEmitter {
constructor (url, {
maxHeaderSize,
idleTimeout,
socketTimeout,
headersTimeout,
socketTimeout,
idleTimeout,
keepAliveTimeout,
maxKeepAliveTimeout,
keepAliveMaxTimeout,
Expand Down Expand Up @@ -649,7 +649,7 @@ function onSocketConnect () {
resume(client)
}

function onSocketTimeout () {
function onIdleTimeout () {
util.destroy(this, new InformationalError('socket idle timeout'))
}

Expand Down Expand Up @@ -688,8 +688,7 @@ function onSocketClose () {

client[kSocket] = null

parser.unconsume()
setImmediate(() => parser.close())
parser.destroy()

if (err.code !== 'UND_ERR_INFO') {
// Evict session on errors.
Expand Down Expand Up @@ -734,7 +733,7 @@ function detachSocket (socket) {
socket[kClient] = null
socket[kError] = null
socket
.removeListener('timeout', onSocketTimeout)
.removeListener('timeout', onIdleTimeout)
.removeListener('session', onSocketSession)
.removeListener('error', onSocketError)
.removeListener('end', onSocketEnd)
Expand Down Expand Up @@ -788,7 +787,7 @@ function connect (client) {
.setNoDelay(true)
.setTimeout(client[kIdleTimeout])
.on(protocol === 'https:' ? 'secureConnect' : 'connect', onSocketConnect)
.on('timeout', onSocketTimeout)
.on('timeout', onIdleTimeout)
.on('error', onSocketError)
.on('end', onSocketEnd)
.on('close', onSocketClose)
Expand Down

0 comments on commit 1d3448a

Please sign in to comment.