This commit is contained in:
jarek committed 2026-07-11 15:31:52 +02:00
1 parent 685132ff89
commit c718ac9a84
101 files changed
+5097 -642

No files matched your search

+3 -3
View File
@@ -18,7 +18,7 @@ export { prefersJSON, sseToJSON } from '$lib/server/sse-parser';
* can reconstruct the same event stream semantics used by the old SSE flow.
*/
export function createJobResponse(
operation: (send: (event: string, data: unknown) => void) => Promise<void>,
operation: (send: (event: string, data: unknown) => void, isCancelled: () => boolean) => Promise<void>,
request?: Request
): Response {
// Backward compat: synchronous JSON path for explicit application/json callers
@@ -31,7 +31,7 @@ export function createJobResponse(
resultData = data;
};
try {
await operation(send);
await operation(send, () => false);
} catch (error) {
resultData = { success: false, error: String(error) };
}
@@ -51,7 +51,7 @@ export function createJobResponse(
appendLine(job, { event, data });
};
operation(send)
operation(send, () => job.cancelRequested === true)
.then(() => {
const resultLine = job.lines.findLast((l) => l.event === 'result');
completeJob(job, resultLine?.data ?? { success: true });