fix: do not count normal dispatcher exits as crashes

The close handler called recordCrash() unconditionally, even for exit
code 0 (normal MAX_REQUESTS restart). After 5 normal cycles within 60s
the dispatcher was permanently disabled. Now only non-zero exits count.
This commit is contained in:
SnapOtter
2026-04-30 18:45:55 +08:00
parent 67fa302376
commit 6d5d0a3673
2 changed files with 57 additions and 2 deletions
+4 -2
View File
@@ -216,12 +216,14 @@ function startDispatcher(): ChildProcess | null {
dispatcherReady = false;
});
child.on("close", () => {
child.on("close", (code) => {
for (const [id, req] of pendingRequests.entries()) {
req.reject(new Error("Python dispatcher exited unexpectedly"));
pendingRequests.delete(id);
}
recordCrash();
if (code !== 0) {
recordCrash();
}
dispatcher = null;
dispatcherReady = false;
});