Skip to content

fix: delay ObjectURL revocation to prevent failed downloads#622

Open
hobostay wants to merge 1 commit intoheygen-com:mainfrom
hobostay:fix/objecturl-revoked-too-early
Open

fix: delay ObjectURL revocation to prevent failed downloads#622
hobostay wants to merge 1 commit intoheygen-com:mainfrom
hobostay:fix/objecturl-revoked-too-early

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 5, 2026

Summary

  • Delay URL.revokeObjectURL from 0ms to 1000ms in frame capture download
  • setTimeout(..., 0) revokes the blob URL before the browser initiates the download, causing empty/failed downloads

Details

Affected file: packages/studio/src/App.tsx (line 875)

When capturing a frame, the code creates a blob URL, triggers a download via link.click(), then immediately schedules revokeObjectURL with setTimeout(..., 0). The 0ms timeout fires on the next microtask, before the browser has started reading from the blob, resulting in a failed or empty download.

Test plan

  • Capture a frame in the studio and verify the download completes successfully
  • Verify the blob URL is eventually cleaned up (no memory leak)

🤖 Generated with Claude Code

…oads

setTimeout(..., 0) revokes the blob URL on the next microtask,
before the browser has initiated the download triggered by
link.click(). This causes empty or failed downloads for frame
captures. Use a 1-second delay to ensure the download starts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@miguel-heygen miguel-heygen self-requested a review May 5, 2026 01:30
Copy link
Copy Markdown
Collaborator

@jrusso1020 jrusso1020 left a comment

Choose a reason for hiding this comment

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

Real race — setTimeout(..., 0) queues the revoke as a macrotask that can fire before the browser kicks off the navigation triggered by link.click(), especially on slower devices. 1000ms is a safe upper bound for download initiation. LGTM.

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.

2 participants