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);