mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-20 12:47:00 +00:00
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:
@@ -19,6 +19,9 @@ export class TestExecutor {
|
|||||||
private totalTests: number = 0
|
private totalTests: number = 0
|
||||||
private currentTest: number = 0
|
private currentTest: number = 0
|
||||||
private logCollector: LogCollector | null = null
|
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
|
private currentTestId: string | null = null
|
||||||
|
|
||||||
constructor(workingDir: string = process.cwd(), logCollector?: LogCollector) {
|
constructor(workingDir: string = process.cwd(), logCollector?: LogCollector) {
|
||||||
|
|||||||
@@ -99,10 +99,16 @@ export class LogCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.process!.on("close", () => {
|
let resolved = false;
|
||||||
this.isRunning = false;
|
const doResolve = () => {
|
||||||
resolve();
|
if (!resolved) {
|
||||||
});
|
resolved = true;
|
||||||
|
this.isRunning = false;
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.process!.on("close", doResolve);
|
||||||
|
|
||||||
this.process!.kill("SIGTERM");
|
this.process!.kill("SIGTERM");
|
||||||
|
|
||||||
@@ -111,7 +117,7 @@ export class LogCollector {
|
|||||||
if (this.isRunning && this.process) {
|
if (this.isRunning && this.process) {
|
||||||
this.process.kill("SIGKILL");
|
this.process.kill("SIGKILL");
|
||||||
}
|
}
|
||||||
resolve();
|
doResolve();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user