fix(whisper): handle model warmup events
- Ignore backend model lifecycle webhooks so model warmup does not mark jobs done early - Parse batched SSE messages and relay model load states during submit retries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -106,6 +106,64 @@ describe('POST /api/webhook/[jobId] — job not found', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ── Ignore backend model lifecycle webhooks ─────────────────────────────────────
|
||||
|
||||
describe('POST /api/webhook/[jobId] — non-job webhook payloads', () => {
|
||||
it('ignores model_ready events sent to job webhooks', async () => {
|
||||
mockGetJob.mockReturnValue(makeJob('job-model-ready'));
|
||||
|
||||
const res = await POST(
|
||||
makeEvent('job-model-ready', {
|
||||
type: 'model_ready',
|
||||
loaded_at: new Date().toISOString()
|
||||
}) as any
|
||||
);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.json()).toEqual({ ok: true, ignored: 'not_a_job_event' });
|
||||
expect(mockSetJobStatus).not.toHaveBeenCalled();
|
||||
expect(mockUpdateJob).not.toHaveBeenCalled();
|
||||
expect(mockWriteOutputs).not.toHaveBeenCalled();
|
||||
expect(mockSendNotification).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ignores model_unloaded events sent to job webhooks', async () => {
|
||||
mockGetJob.mockReturnValue(makeJob('job-model-unloaded'));
|
||||
|
||||
const res = await POST(
|
||||
makeEvent('job-model-unloaded', {
|
||||
type: 'model_unloaded',
|
||||
unloaded_at: new Date().toISOString()
|
||||
}) as any
|
||||
);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.json()).toEqual({ ok: true, ignored: 'not_a_job_event' });
|
||||
expect(mockSetJobStatus).not.toHaveBeenCalled();
|
||||
expect(mockUpdateJob).not.toHaveBeenCalled();
|
||||
expect(mockWriteOutputs).not.toHaveBeenCalled();
|
||||
expect(mockSendNotification).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ignores payloads with invalid status values', async () => {
|
||||
mockGetJob.mockReturnValue(makeJob('job-invalid-status'));
|
||||
|
||||
const res = await POST(
|
||||
makeEvent('job-invalid-status', {
|
||||
id: 'bogus-whisper-id',
|
||||
status: 'model_ready',
|
||||
segments: []
|
||||
}) as any
|
||||
);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.json()).toEqual({ ok: true, ignored: 'not_a_job_event' });
|
||||
expect(mockSetJobStatus).not.toHaveBeenCalled();
|
||||
expect(mockUpdateJob).not.toHaveBeenCalled();
|
||||
expect(mockWriteOutputs).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// ── Local cancellation guard ──────────────────────────────────────────────────
|
||||
|
||||
describe('POST /api/webhook/[jobId] — locally cancelled job', () => {
|
||||
|
||||
Reference in New Issue
Block a user