From 15ce5b4164378f7398ff84cabe8ee97eef5cfd1b Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Sun, 11 Aug 2024 22:17:08 +0800 Subject: [PATCH] fix: change `abort` listener to `aborted` event (#8282) --- .changeset/strong-spiders-grab.md | 5 +++++ .../src/differentialDownloader/DifferentialDownloader.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/strong-spiders-grab.md diff --git a/.changeset/strong-spiders-grab.md b/.changeset/strong-spiders-grab.md new file mode 100644 index 00000000000..6a36453db45 --- /dev/null +++ b/.changeset/strong-spiders-grab.md @@ -0,0 +1,5 @@ +--- +"electron-updater": patch +--- + +fix aborted event diff --git a/packages/electron-updater/src/differentialDownloader/DifferentialDownloader.ts b/packages/electron-updater/src/differentialDownloader/DifferentialDownloader.ts index dea23481dfc..bc51881a2a3 100644 --- a/packages/electron-updater/src/differentialDownloader/DifferentialDownloader.ts +++ b/packages/electron-updater/src/differentialDownloader/DifferentialDownloader.ts @@ -233,7 +233,7 @@ export abstract class DifferentialDownloader { const request = this.httpExecutor.createRequest(requestOptions, response => { response.on("error", reject) - response.on("abort", () => { + response.on("aborted", () => { reject(new Error("response has been aborted by the server")) }) // Electron net handles redirects automatically, our NodeJS test server doesn't use redirects - so, we don't check 3xx codes. @@ -295,6 +295,11 @@ export abstract class DifferentialDownloader { return } + response.on("error", reject) + response.on("aborted", () => { + reject(new Error("response has been aborted by the server")) + }) + response.on("data", dataHandler) response.on("end", () => resolve()) })