feat: add sleep to translate-audio call#214
Open
walkerfrankenberg wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
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.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 asUnknown error.What was changed
setTimeout. Replaced the homemadesleepstep (setTimeoutinside a"use step", which held the function for the full wait) with the Vercel Workflow DevKit's nativesleepimported fromworkflow. Poll loops now suspend the workflow at zero compute and no longer accumulate against the function's max-duration limit."use step", so a durablesleepcouldn't suspend from within it. The loop now runs at orchestration level, and the per-attempt asset fetch was extracted into a newretrieveAssetstep.source_urlto ElevenLabs instead of downloading + re-uploading.createElevenLabsDubbingJobnow sends the signed Muxaudio.m4aURL assource_urlso ElevenLabs fetches the media itself. RemovedfetchAudioFromMuxand theaudioBuffermultipart-file upload — this eliminates the 77 MB runner transfer that was timing out.sleep()requires the workflow runtime, so it can't run via direct function call. Removedtests/integration/translate-audio.test.tsand its dedicated CI job (translate-audio-integration.yml), and cleaned the now-stale--excludefromintegration-tests.yml. The.test.workflowdevkit.tstest (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
sleepinstead of asetTimeoutstep, and the static-rendition wait loop runs at orchestration level (newretrieveAssetstep per poll) so waits suspend without holding the function open. ElevenLabs dubbing is started withsource_url(signed Muxaudio.m4a) instead of downloading audio onto the runner and uploading multipartfile;fetchAudioFromMuxis removed. Dubbing status polling exits ondubbed, treatsfailedas aMuxAiError, and relies on the same durable sleep.wrapErrorgainsextractErrorDetailso errors deserialized across step boundaries still surface a realmessageinstead of Unknown error.CI drops the plain
translate-audio.test.tsandtranslate-audio-integration.yml(workflowsleepneeds 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.