fix: skip queueLength===0 completion branch when session returns 404
This commit is contained in:
@@ -94,9 +94,11 @@ export const summarizeHandler: EventHandler = {
|
||||
const statusResponse = await workerHttpRequest(`/api/sessions/status?contentSessionId=${encodeURIComponent(sessionId)}`, {
|
||||
timeoutMs: 5000
|
||||
});
|
||||
if (statusResponse.ok) {
|
||||
const status = await statusResponse.json() as { queueLength?: number; summaryStored?: boolean | null };
|
||||
if ((status.queueLength ?? 0) === 0) {
|
||||
const queueLength = status.queueLength ?? 0;
|
||||
// Only treat an empty queue as completion when the session exists (non-404).
|
||||
// A 404 means the session was not found — not that processing finished.
|
||||
if (queueLength === 0 && statusResponse.status !== 404) {
|
||||
summaryStored = status.summaryStored ?? null;
|
||||
logger.info('HOOK', 'Summary processing complete', {
|
||||
waitedMs: Date.now() - waitStart,
|
||||
@@ -112,7 +114,6 @@ export const summarizeHandler: EventHandler = {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Worker may be busy — keep polling
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user