Skip to content

Commit

Permalink
Remove callback and rely on timeout event for destroying request
Browse files Browse the repository at this point in the history
  • Loading branch information
eablack committed Dec 18, 2024
1 parent 0d7902b commit b2f7813
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,11 @@ export class HTTP<T> {
}

if (this.options.timeout) {
this.request.setTimeout(this.options.timeout, () => {
debug(`← ${this.method} ${this.url} TIMED OUT`)
this.request.setTimeout(this.options.timeout)
this.request.on('timeout', () => {
debug(`← ${this.method} ${this.url} TIMEOUT`)
this.request.destroy()
reject()
})
}

Expand Down

0 comments on commit b2f7813

Please sign in to comment.