Fix double-resolve bug in LogCollector.stop()

- stop() could resolve promise twice (from close event AND timeout)
- Add resolved flag to ensure single resolution
- Add comment about parallel execution limitation in executor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Shang Chieh Tseng
2025-12-17 17:48:20 +08:00
parent 2c5094db92
commit bf2c321626
2 changed files with 14 additions and 5 deletions

View File

@@ -19,6 +19,9 @@ export class TestExecutor {
private totalTests: number = 0
private currentTest: number = 0
private logCollector: LogCollector | null = null
// Note: currentTestId is shared state - LogCollector only works correctly
// with sequential execution (concurrency=1). Parallel execution will have
// inaccurate log boundaries.
private currentTestId: string | null = null
constructor(workingDir: string = process.cwd(), logCollector?: LogCollector) {

View File

@@ -99,10 +99,16 @@ export class LogCollector {
}
return new Promise((resolve) => {
this.process!.on("close", () => {
let resolved = false;
const doResolve = () => {
if (!resolved) {
resolved = true;
this.isRunning = false;
resolve();
});
}
};
this.process!.on("close", doResolve);
this.process!.kill("SIGTERM");
@@ -111,7 +117,7 @@ export class LogCollector {
if (this.isRunning && this.process) {
this.process.kill("SIGKILL");
}
resolve();
doResolve();
}, 5000);
});
}