Skip to content

Commit

Permalink
fix: retry renaming update file when EBUSY error occurs due to file lock
Browse files Browse the repository at this point in the history
  • Loading branch information
juwonjung-hdj committed Aug 30, 2024
1 parent 977acaf commit b6b99c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/electron-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"out"
],
"dependencies": {
"builder-util": "workspace:*",
"builder-util-runtime": "workspace:*",
"fs-extra": "^10.1.0",
"js-yaml": "^4.1.0",
Expand Down
10 changes: 9 additions & 1 deletion packages/electron-updater/src/AppUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { retry } from "builder-util"
import {
AllPublishOptions,
asArray,
Expand Down Expand Up @@ -712,7 +713,14 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
const tempUpdateFile = await createTempUpdateFile(`temp-${updateFileName}`, cacheDir, log)
try {
await taskOptions.task(tempUpdateFile, downloadOptions, packageFile, removeFileIfAny)
await rename(tempUpdateFile, updateFile)
await retry(
() => rename(tempUpdateFile, updateFile),
60,
500,
0,
0,
error => error instanceof Error && /^EBUSY:/.test(error.message)
)
} catch (e: any) {
await removeFileIfAny()

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6b99c5

Please sign in to comment.