Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 16:54:30 +00:00
parent 35f1961385
commit 17223bdff7
20 changed files with 1756 additions and 646 deletions

55
node_modules/nock/lib/socket.js generated vendored
View file

@ -7,9 +7,12 @@ module.exports = class Socket extends EventEmitter {
constructor(options) {
super()
// Pretend this is a TLSSocket
if (options.proto === 'https') {
// https://github.com/nock/nock/issues/158
this.authorized = true
// https://github.com/nock/nock/issues/2147
this.encrypted = true
}
this.bufferSize = 0
@ -18,14 +21,13 @@ module.exports = class Socket extends EventEmitter {
this.readable = true
this.pending = false
this.destroyed = false
this.connecting = false
this.connecting = true
// totalDelay that has already been applied to the current
// request/connection, timeout error will be generated if
// it is timed-out.
this.totalDelayMs = 0
// Maximum allowed delay. Null means unlimited.
this.timeoutMs = null
// Undocumented flag used by ClientRequest to ensure errors aren't double-fired
this._hadError = false
// Maximum allowed delay. 0 means unlimited.
this.timeout = 0
const ipv6 = options.family === 6
this.remoteFamily = ipv6 ? 'IPv6' : 'IPv4'
@ -48,16 +50,22 @@ module.exports = class Socket extends EventEmitter {
}
setTimeout(timeoutMs, fn) {
this.timeoutMs = timeoutMs
this.timeout = timeoutMs
if (fn) {
this.once('timeout', fn)
}
return this
}
/**
* Artificial delay that will trip socket timeouts when appropriate.
*
* Doesn't actually wait for time to pass.
* Timeout events don't necessarily end the request.
* While many clients choose to abort the request upon a timeout, Node itself does not.
*/
applyDelay(delayMs) {
this.totalDelayMs += delayMs
if (this.timeoutMs && this.totalDelayMs > this.timeoutMs) {
if (this.timeout && delayMs > this.timeout) {
debug('socket timeout')
this.emit('timeout')
}
@ -69,12 +77,31 @@ module.exports = class Socket extends EventEmitter {
).toString('base64')
}
/**
* Denotes that no more I/O activity should happen on this socket.
*
* The implementation in Node if far more complex as it juggles underlying async streams.
* For the purposes of Nock, we just need it to set some flags and on the first call
* emit a 'close' and optional 'error' event. Both events propagate through the request object.
*/
destroy(err) {
if (this.destroyed) {
return this
}
debug('socket destroy')
this.destroyed = true
this.readable = this.writable = false
if (err) {
this.emit('error', err)
}
this.readableEnded = this.writableFinished = true
process.nextTick(() => {
if (err) {
this._hadError = true
this.emit('error', err)
}
this.emit('close')
})
return this
}
}