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:
parent
5dfcf1eaca
commit
5c29d5338f
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue