Skip to content

Fix: Prevent premature state update and export corruption in TrimControl#957

Open
Sandeep6135 wants to merge 3 commits into
magic-peach:mainfrom
Sandeep6135:fix-trim-state-bug
Open

Fix: Prevent premature state update and export corruption in TrimControl#957
Sandeep6135 wants to merge 3 commits into
magic-peach:mainfrom
Sandeep6135:fix-trim-state-bug

Conversation

@Sandeep6135
Copy link
Copy Markdown

Description

This pull request fixes a critical state corruption bug in the video trimming workflow.
The Problem:
Previously, the handleEnd function in TrimControl updated the global recipe.trimEnd state before validating the user's input. If a user entered an invalid value (resulting in NaN) or an out-of-bounds value, the NaN value was committed to the state despite the UI showing an error. This bypassed the pre-export validation (NaN > duration evaluates to false), passing corrupted state to FFmpeg and causing the video export to fail/crash.
The Solution:
Moved the onChange({ trimEnd: n }) state dispatch to the very end of the handleEnd function. The global recipe state is now only updated after all input validation checks (like isNaN, positive integer bounds, and duration checks) pass successfully.
Testing:

  • Verified that entering invalid characters correctly shows an inline error without persisting to the global recipe.
  • Verified that valid inputs successfully update the state.
  • Verified that corrupted values no longer bypass the export validations.

Closes #954

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

@Sandeep6135 is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

✅ PR Format Check Passed — @Sandeep6135

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Sandeep6135!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

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

Labels

level:beginner Beginner level - 20 pts type:bug Bug fix type:design UI/UX design type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] State corruption and export failure due to premature state update in 'TrimControl'

1 participant