mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 14:38:21 +00:00
fix(transcode): preserve trashed status during background jobs and handle permanent purge (#416)
* fix(transcode): preserve trashed status during background jobs and handle permanent purge * fix(workflow): clear heartbeat and add info logs on task cancellation * fix(transcode): terminate media processes and guard task activities on cancellation - Pass AbortSignal to ffmpeg and pdftoppm child processes in transcodeService to terminate processes on task cancellation - Add local task AbortController context and cancellation guards in executeActivity to prevent subsequent workflow activities - Forward taskId and cancellation signals in transcode, screenshot, and PDF activities - Use updateMany instead of update in task activities to eliminate Prisma P2025 errors on purged task records * fix(workflow): allow cleanup activities in finally blocks during task cancellation Remove blanket cancellation check in executeActivity so that workflows can execute cleanup and failure handling activities in catch and finally blocks upon cancellation, while relying on AbortSignal in active activities to abort execution. * docs(changelog): improve user friendliness of changelog entries and formatting example * docs(agents): update changelog guidelines to emphasize end-user friendly descriptions * fix(transcode): handle queued cancellation and delete races in media workflow
This commit is contained in:
@@ -18,6 +18,20 @@ export function registerWorkflowTrigger(cb: WorkflowTriggerCallback) {
|
||||
onWorkflowTaskCreated = cb
|
||||
}
|
||||
|
||||
// Global callback for workflow task cancellation (decouples db/core packages from workflow engine)
|
||||
type WorkflowCancelCallback = (taskId: string) => Promise<void>
|
||||
let onWorkflowTaskCancelled: WorkflowCancelCallback | null = null
|
||||
|
||||
export function registerWorkflowCancel(cb: WorkflowCancelCallback) {
|
||||
onWorkflowTaskCancelled = cb
|
||||
}
|
||||
|
||||
export async function cancelWorkflowTask(taskId: string): Promise<void> {
|
||||
if (onWorkflowTaskCancelled) {
|
||||
await onWorkflowTaskCancelled(taskId)
|
||||
}
|
||||
}
|
||||
|
||||
const isTest = process.env.NODE_ENV === 'test'
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
|
||||
Reference in New Issue
Block a user