Skip to content

Commit

Permalink
fix(fetch-engine): Prevent macOS from killing node on engine update
Browse files Browse the repository at this point in the history
Fix #14058
  • Loading branch information
SevInf committed Jul 14, 2022
1 parent 215a124 commit 210f69d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/fetch-engine/src/downloadZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export async function downloadZip(
onFailedAttempt: (err) => debug(err),
},
)
// without removing the file first,
// macOS Gatekeeper can sometimes complain
// about incorrect binary signature and kill node process
// https://openradar.appspot.com/FB8914243
removeFileIfExists(target)
fs.copyFileSync(partial, target)

// it's ok if the unlink fails
Expand All @@ -125,3 +130,13 @@ export async function downloadZip(

return result as DownloadResult
}

function removeFileIfExists(filePath: string) {
try {
fs.unlinkSync(filePath)
} catch (e) {
if (e.code !== 'ENOENT') {
throw e
}
}
}

0 comments on commit 210f69d

Please sign in to comment.