Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retry renaming update file when EBUSY error occurs due to file lock #8437

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:*",
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
"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.

Loading