-
-
Notifications
You must be signed in to change notification settings - Fork 969
Closed
Labels
documentationThe issue will improve the docsThe issue will improve the docsenhancementThis change will extend Got featuresThis change will extend Got features
Description
Describe the bug
- Node.js version: 12.6.1
- OS & version: Macos 10.14
Actual behavior
When isStream: true
is set and request results in HTTPError, the stream emits error
event. The emit handler is only called with error
argument and body
and response
arguments are undefined
.
...
Expected behavior
As per the docs, the body
and response
arguments should be set with error
event.
...
Code to reproduce
const got = require('got');
let stream = got("https://www.google.com/non-existant-path", {
isStream: true,
method: "GET",
headers: {}
});
stream.on("response", (response) => {
console.log(response.headers);
console.log(response.statusCode)
});
stream.on("error", (err, body, response) => {
// err is set
console.log(err);
// body should have been set but it's undefined
console.log(body);
// response should have been set but it's undefined.
console.log(response);
});
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
Metadata
Metadata
Assignees
Labels
documentationThe issue will improve the docsThe issue will improve the docsenhancementThis change will extend Got featuresThis change will extend Got features