Skip to content

Commit 1607820

Browse files
authored
fix: cleanup actool output file handle after spawn (#9373)
1 parent aac6b38 commit 1607820

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.changeset/spotty-parents-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix: cleanup actool output file handle after spawn

packages/app-builder-lib/src/util/macosIconComposer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ async function checkActoolVersion(tmpDir: string) {
2121

2222
let versionInfo: Record<string, Record<string, string>> | undefined = undefined
2323

24+
let acToolOutputFile: fs.FileHandle | null = null
25+
let errorQueued: Error | null = null
2426
try {
25-
const acToolOutputFile = await fs.open(acToolOutputFileName, "w")
27+
acToolOutputFile = await fs.open(acToolOutputFileName, "w")
2628
await spawn("actool", ["--version"], { stdio: ["ignore", acToolOutputFile.fd, acToolOutputFile.fd] })
2729
const acToolVersionOutput = await fs.readFile(acToolOutputFileName, "utf8")
2830
versionInfo = plist.parse(acToolVersionOutput) as Record<string, Record<string, string>>
29-
} catch {
30-
throw INVALID_ACTOOL_VERSION_ERROR
31+
} catch (e: any) {
32+
errorQueued = e
33+
} finally {
34+
if (acToolOutputFile) {
35+
await acToolOutputFile.close()
36+
}
3137
}
3238

33-
if (!versionInfo || !versionInfo["com.apple.actool.version"] || !versionInfo["com.apple.actool.version"]["short-bundle-version"]) {
39+
if (errorQueued || !versionInfo || !versionInfo["com.apple.actool.version"] || !versionInfo["com.apple.actool.version"]["short-bundle-version"]) {
3440
throw INVALID_ACTOOL_VERSION_ERROR
3541
}
3642

0 commit comments

Comments
 (0)