From e8007efcafe1ecae7831ef5d8a2e4443b34e2a84 Mon Sep 17 00:00:00 2001 From: Mohammad Beheshti Date: Thu, 25 Jan 2024 21:27:10 +0100 Subject: [PATCH 1/2] Fix request timeout handling in parser.js --- lib/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index 7d71431..80efde4 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -98,7 +98,7 @@ class Parser { }) req.on('error', reject); timeout = setTimeout(() => { - return reject(new Error("Request timed out after " + this.options.timeout + "ms")); + req.destroy(new Error("Request timed out after " + this.options.timeout + "ms")); }, this.options.timeout); }).then(data => { clearTimeout(timeout); From 33e1408f0cbe3229cfe61aebaf3edf7fa9800cb8 Mon Sep 17 00:00:00 2001 From: Robert Brennan Date: Mon, 12 Feb 2024 11:28:30 -0500 Subject: [PATCH 2/2] Update lib/parser.js --- lib/parser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index d655ddc..6aaccb0 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -118,7 +118,9 @@ class Parser { }) req.on('error', reject); timeout = setTimeout(() => { - req.destroy(new Error("Request timed out after " + this.options.timeout + "ms")); + let err = new Error("Request timed out after " + this.options.timeout + "ms"); + req.destroy(err); + reject(err); }, this.options.timeout); }).then(data => { clearTimeout(timeout);