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:
Yiling-J
2026-09-19 10:40:49 +08:00
committed by GitHub
parent 145aa6bfb4
commit b52b2ce7d8
25 changed files with 1172 additions and 65 deletions
@@ -68,6 +68,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
const posterResult = await executeActivity(workerQueue, extractPosterActivity, {
assetKey: key,
posterSpec,
taskId: task.id,
})
mediaInfo.poster = posterResult.poster
await executeActivity(workerQueue, updateAssetMediaActivity, {
@@ -98,6 +99,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
}
const videoTranscode = await executeActivity(workerQueue, transcodeVideoActivity, {
taskId: task.id,
assetKey: key,
filePath,
videoSpec,
@@ -119,6 +121,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
const isAudio = mediaInfo.proxyType === 'audio'
if (isAudio && metadata) {
const audioTranscode = await executeActivity(workerQueue, transcodeAudioActivity, {
taskId: task.id,
assetKey: key,
filePath,
threads: spec.threads,
@@ -150,6 +153,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
}
const spriteResult = await executeActivity(workerQueue, generateSpriteActivity, {
taskId: task.id,
assetKey: key,
filePath,
spriteSpec,