Skip to content

feat: add sleep to translate-audio call#214

Open
walkerfrankenberg wants to merge 3 commits into
mainfrom
wf/translate-audio-sleep
Open

feat: add sleep to translate-audio call#214
walkerfrankenberg wants to merge 3 commits into
mainfrom
wf/translate-audio-sleep

Conversation

@walkerfrankenberg

@walkerfrankenberg walkerfrankenberg commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Overview

Fixes audio dubbing failing on long-form content (55m/90m assets) in the Vercel Workflows runtime. Two root causes are addressed in src/workflows/translate-audio.ts: poll loops were holding the function open against the ~20-min max-duration ceiling, and the 77 MB source audio was being downloaded onto the runner over a degraded egress path to Mux. Short assets already worked; longer ones hit the wall and surfaced as Unknown error.

What was changed

  • Durable sleep instead of setTimeout. Replaced the homemade sleep step (setTimeout inside a "use step", which held the function for the full wait) with the Vercel Workflow DevKit's native sleep imported from workflow. Poll loops now suspend the workflow at zero compute and no longer accumulate against the function's max-duration limit.
  • Hoisted the static-rendition poll loop out of a step. That loop previously lived entirely inside one "use step", so a durable sleep couldn't suspend from within it. The loop now runs at orchestration level, and the per-attempt asset fetch was extracted into a new retrieveAsset step.
  • Pass source_url to ElevenLabs instead of downloading + re-uploading. createElevenLabsDubbingJob now sends the signed Mux audio.m4a URL as source_url so ElevenLabs fetches the media itself. Removed fetchAudioFromMux and the audioBuffer multipart-file upload — this eliminates the 77 MB runner transfer that was timing out.
  • Dropped the plain-execution test for this workflow. sleep() requires the workflow runtime, so it can't run via direct function call. Removed tests/integration/translate-audio.test.ts and its dedicated CI job (translate-audio-integration.yml), and cleaned the now-stale --exclude from integration-tests.yml. The .test.workflowdevkit.ts test (and its CI job) already cover the same real-API assertions through the runtime that ships — this is now the only faithful way to exercise the workflow.

Note

Medium Risk
Changes core long-running dubbing orchestration and external API input (URL vs file upload); behavior shift is intentional but affects production audio translation paths.

Overview
Fixes translate-audio failing on long-form assets in the Vercel Workflows runtime by avoiding max-duration timeouts and large runner downloads.

The workflow now uses Workflow DevKit sleep instead of a setTimeout step, and the static-rendition wait loop runs at orchestration level (new retrieveAsset step per poll) so waits suspend without holding the function open. ElevenLabs dubbing is started with source_url (signed Mux audio.m4a) instead of downloading audio onto the runner and uploading multipart file; fetchAudioFromMux is removed. Dubbing status polling exits on dubbed, treats failed as a MuxAiError, and relies on the same durable sleep.

wrapError gains extractErrorDetail so errors deserialized across step boundaries still surface a real message instead of Unknown error.

CI drops the plain translate-audio.test.ts and translate-audio-integration.yml (workflow sleep needs the runtime); the main integration job runs the full suite without excluding that test file.

Reviewed by Cursor Bugbot for commit 5e3891c. Bugbot is set up for automated code reviews on this repo. Configure here.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@walkerfrankenberg walkerfrankenberg requested a review from a team July 9, 2026 23:45
@snyk-io

snyk-io Bot commented Jul 9, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant