Skip to content

Commit

Permalink
fix:(electron-updater) not rejecting with error when response stream …
Browse files Browse the repository at this point in the history
…gets an error (#4586)
  • Loading branch information
kevinlinv authored and develar committed Jan 16, 2020
1 parent 71726a7 commit 891a633
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/builder-util-runtime/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Please double check that your authentication token is correct. Due to security r
response.setEncoding("utf8")

let data = ""
response.on("error", reject)
response.on("data", (chunk: string) => data += chunk)
response.on("end", () => {
try {
Expand Down Expand Up @@ -249,6 +250,10 @@ Please double check that your authentication token is correct. Due to security r
return
}

// It is possible for the response stream to fail, e.g. when a network is lost while
// response stream is in progress. Stop waiting and reject so consumer can catch the error.
response.on("error", options.callback)

// this code not relevant for Electron (redirect event instead handled)
const redirectUrl = safeGetHeader(response, "location")
if (redirectUrl != null) {
Expand Down

0 comments on commit 891a633

Please sign in to comment.