Merge current master into PR #219

Refresh the background-task branch onto the latest repository baseline before applying review feedback. This preserves merge ancestry, incorporates the current CI and package-structure changes, and ensures the review fixes are validated against the code that will actually receive the PR.
This commit is contained in:
Tianyi Cui
2026-07-15 21:30:21 +08:00
41 changed files with 863 additions and 359 deletions

View File

@@ -95,8 +95,19 @@ let consumer: string | undefined
let child: ReturnType<typeof spawn> | undefined
afterEach(async () => {
if (child !== undefined) { child.kill('SIGKILL'); child = undefined }
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true })
if (child !== undefined) {
const proc = child
child = undefined
// Windows retains the child's cwd and session-log handles until process
// teardown completes, so await exit before removing the temp directory.
if (proc.exitCode === null && proc.signalCode === null) {
const exited = new Promise<void>((resolve) => { proc.once('exit', () => { resolve() }) })
proc.kill('SIGKILL')
await exited
}
}
// Windows can briefly retain released handles after exit; retry removal.
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
consumer = undefined
})

View File

@@ -116,7 +116,8 @@ function runBuiltBin(cwd: string, configArg: string, line: string): Promise<{ st
let consumer: string | undefined
afterEach(async () => {
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true })
// Windows can briefly retain released handles after exit; retry removal.
if (consumer !== undefined) await rm(consumer, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
consumer = undefined
})