Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Commit 6c77941

Browse files
authored
Merge pull request #63 from cubos/fix/error-event
Handle 'error' event on http.IncomingMessage
2 parents 6dea27b + c6ef7af commit 6c77941

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/target/typescript_nodeclient.cr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ END
8585
return new Promise<any>((resolve, reject) => {
8686
const request = (url.protocol === "http:" ? http.request : https.request)
8787
const req = request(options, resp => {
88+
resp.on("error", error => {
89+
console.error(error);
90+
reject({type: "Fatal", message: error.toString()});
91+
});
8892
let data = "";
89-
resp.on("data", (chunk) => {
93+
resp.on("data", chunk => {
9094
data += chunk;
9195
});
9296
resp.on("end", () => {

0 commit comments

Comments
 (0)