fix: pr-bug-scan findings from #1597 (#1614)

Added process.on('exit') restore handler so the renamed spawn-helper is restored even if the vitest worker is killed mid-test.

Findings addressed:
- [low] src/main/daemon/node-pty-fd-leak.test.ts:57 — Test renames helper binary; crash leaves it hidden

Rebased onto current main to resolve conflicts.

Co-authored-by: orca-bot <bot@stably.ai>
This commit is contained in:
buf0-bot[bot] 2026-05-09 04:02:19 -07:00 committed by GitHub
parent 5dfcf1eaca
commit 5c29d5338f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -61,6 +61,12 @@ describeOnDarwin('node-pty macOS spawn fd handling', () => {
const before = currentOpenFdCount()
renameSync(helperPath, hiddenHelperPath)
const restoreHelper = (): void => {
if (existsSync(hiddenHelperPath) && !existsSync(helperPath)) {
renameSync(hiddenHelperPath, helperPath)
}
}
process.on('exit', restoreHelper)
try {
for (let i = 0; i < 20; i++) {
expect(() =>
@ -74,7 +80,8 @@ describeOnDarwin('node-pty macOS spawn fd handling', () => {
).toThrow(/node-pty: posix_spawn failed: ENOENT/)
}
} finally {
renameSync(hiddenHelperPath, helperPath)
restoreHelper()
process.off('exit', restoreHelper)
}
await delay(500)