You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
export: a failed or panicked export removes the files it opened, as a cancel does (#4142) - #4224
What the user saw. A cancelled export removed every file it had opened, but one that failed part way (a write error, a full disk) or panicked kept them: a truncated .mp4, or the frames of a sequence written so far, sat at the output path looking like a finished render.
Cause.export_async called Cx::remove_cancelled_outputs only for ExportError::Cancelled. Every other error returned with the files in place, and a panic in export_with skipped the cleanup entirely, although Cx::create had already recorded every path the export opened (overflow paths included).
What changed (crates/export only):
remove_cancelled_outputs is now remove_written_outputs, used for every non-success. Same list, same rule that a file already gone is fine; it returns the first file it could not remove instead of building the error itself.
export_async runs it on any Err, before the render log is written. The caller gets the export's own error with its variant unchanged; a file that could not be removed is appended (…; cannot remove partial output <path>: <why>). A cancel behaves exactly as before, including its cannot remove cancelled output i/o error.
A drop guard, RemoveOutputs, beside RenderEnd, removes the files when the export panics, and the panic continues to the caller. It also fires when the export's future is dropped before it finishes; in the browser outputs go through a sink, which records nothing, so that changes nothing there.
The render log is not touched: a failure still writes it as the Log setting says. Files written through a sink and Render Queue items that finished before a later item failed are out of scope, as the issue says.
Test.render_settings::failed_or_panicked_export_removes_only_files_it_opened (crates/export/tests/it) runs three exports into a folder with decoy files and a folder sitting where frame 20 of the sequence wants to go:
a PNG sequence that fails at frame 20: the error is still ExportError::Io, and no frames remain;
a PNG sequence and an H.264 movie whose progress callback panics once the output is on disk: the panic reaches the caller, and no output remains.
Each time the decoys, the blocking folder and (for the failure) the render log are all that is left. I saw each case fail without its part of the fix: with the source change stashed, the failed sequence left frames 0–29; with only the guard disarmed, the panicked sequence left frames 0–9 and the panicked movie left clip.mp4. cancelled_export_removes_only_files_it_opened passes unchanged.
Not tested: the message for a removal that fails (a read-only folder; that is platform-specific to set up and the text is one format! you can check by reading), and the issue's Render Queue integration case (a later item failing leaves an earlier item's files). The Render Queue runs each item as its own export, whose list holds only that item's files.
Verification. On macOS (aarch64) only: cargo fmt -p effectcraft-export --check, cargo clippy -p effectcraft-export --all-targets -- -D warnings (clean), cargo test -p effectcraft-export (48 unit and 130 integration tests pass, 6 ignored as on main). The full cargo xtask ci did not run; I rely on upstream CI for the other crates and for Windows.
Summary by CodeRabbit
Bug Fixes
Failed, cancelled, or interrupted exports now clean up output files created during that export, while preserving files that were already present.
Cleanup failures are included in the reported export error, making it clearer when generated files could not be removed.
Export failures continue to be reported, and panics still propagate to the caller.
Exports now remove files they opened after errors, panics, or dropped futures. Cleanup failures are added to returned errors where supported. Tests check that partial outputs are removed and files the export did not open remain intact.
Changes: Export cleanup
Layer / File(s)
Summary
Output cleanup and error reporting crates/export/src/pipeline.rs, crates/export/src/lib.rs
remove_cancelled_outputs is replaced by remove_written_outputs, which reports the first removal failure. Export errors incorporate cleanup failure details; a cleanup failure changes cancellation to an I/O error.
Export cleanup flow and tests crates/export/src/lib.rs, crates/export/tests/it/render_settings.rs
export_async removes opened outputs after errors. A drop guard attempts cleanup if the export panics or its future is dropped. Tests check failure and panic cleanup, preservation of unopened files, and retention of the render log on I/O failure.
sequenceDiagram
participant export_async
participant export_with
participant RemoveOutputs
participant Cx
participant RenderLog
export_async->>RemoveOutputs: arm cleanup guard
export_async->>export_with: run export
alt export returns an error
export_with-->>export_async: return export error
export_async->>Cx: remove_written_outputs
Cx-->>export_async: return removal result
export_async->>RenderLog: write render log
else export panics or future is dropped
RemoveOutputs->>Cx: remove_written_outputs during drop
Cx-->>RemoveOutputs: return removal result
end
Loading
Possibly related issues
Issue 1426: The cleanup covers a failed encode that leaves a stub at the output path. Exit-code reporting and overwrite protection are not addressed.
Failed or panicked exports now remove the files they opened. In the unlikely case that accelerator teardown panics after a failure, partial outputs could remain. This is a minor edge case and does not block merging.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title states the main behavior change: a failed or panicked export now removes the files it opened, matching existing cancel behavior. The changeset matches this: ExportError::with_unremoved appen…
Linked Issues check
Directly linked issue #4142 requires cleanup of recorded outputs on every non-success, panic cleanup during unwinding, error variant preserved with removal failures appended, unchanged cancel behavior…
Out of Scope Changes check
All changed code is in crates/export, as the issue scope requires. The changes are: ExportError::with_unremoved and RemoveOutputs in lib.rs; the rename of remove_cancelled_outputs to `remove…
Full details: Title check
Explanation
The title states the main behavior change: a failed or panicked export now removes the files it opened, matching existing cancel behavior. The changeset matches this: ExportError::with_unremoved appends removal failures, export_async cleans up after errors before writing the render log, and a RemoveOutputs drop guard handles panics and dropped futures. The referenced issue number (#4142) in the title differs from the PR objectives' PR number (#4224), but the title itself accurately describes the change. The title is 89 characters, slightly above a short ideal, but it remains a single clear sentence.
Full details: Linked Issues check
Explanation
Directly linked issue #4142 requires cleanup of recorded outputs on every non-success, panic cleanup during unwinding, error variant preserved with removal failures appended, unchanged cancel behavior, and no touching of unopened files.
Evidence at head, crates/export/src/lib.rs, export_async:
Req 1: r = r.map_err(|e| match cx.remove_written_outputs() {...}) runs on every Err, before cx.write_log. This covers the non-cancel failures.
Req 2: RemoveOutputs(Some(&cx)) is a drop guard. It is disarmed (outputs.0 = None) only after export_with returns, so a panic runs the removal during unwinding and the panic continues.
Req 3: ExportError::with_unremoved keeps the variant for Io, Encode, Unsupported, and NoComp. It appends ; cannot remove partial output <why>. A cancel maps to the removal's Io error, as before.
Req 4: the cancelled branch still returns after cleanup, and the cancel path is unchanged.
Req 5: the change relies on Cx::create recording only opened paths. That behavior is stated in the issue and the PR. I did not read the pipeline.rs body at head (the blob diff was unavailable), so this rests on the PR summary and the issue.
Tests: the PR reports failed_or_panicked_export_removes_only_files_it_opened and its failing-without-fix runs. I did not read the test file, so its results are taken from the PR description.
Not covered by the PR and not verified: the removal-failure message test, the Render Queue integration case, and panic-safety of the removal itself (the removal is in the drop guard). The issue's coding requirements 1 to 5 are otherwise met by the code shown.
Full details: Out of Scope Changes check
Explanation
All changed code is in crates/export, as the issue scope requires. The changes are: ExportError::with_unremoved and RemoveOutputs in lib.rs; the rename of remove_cancelled_outputs to remove_written_outputs in pipeline.rs; and the new test in tests/it/render_settings.rs. Each one serves issue #4142. The render log path (write_log) is unchanged, which matches the issue's out-of-scope list. No sink, Render Queue, or other-crate change appears in the summary. The Definition of Done's documentation and release-note items are non-coding and are not part of this assessment.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
crates/export/src/lib.rs-249-249: 1
249-249: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Keep the cleanup guard armed through accelerator teardown.
If export_with fails after writing frames and Accelerator::render_end then panics, this assignment disables cleanup before drop(render). The panic skips the explicit cleanup below, so partial frames remain. Keep the guard armed through drop(render), then disarm it before render-log creation. Normal teardown must still retain successful outputs. (raw.githubusercontent.com)
Reviewing files that changed from the base of the PR and between 01a61a9 and beeb0b2.
Files selected for processing: 3
crates/export/src/lib.rs
crates/export/src/pipeline.rs
crates/export/tests/it/render_settings.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This branch has not been deployed
No deployments
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
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.
A render that fails or crashes part way no longer leaves a truncated movie or half an image sequence at its output path.
Fixes #4142.
What the user saw. A cancelled export removed every file it had opened, but one that failed part way (a write error, a full disk) or panicked kept them: a truncated
.mp4, or the frames of a sequence written so far, sat at the output path looking like a finished render.Cause.
export_asynccalledCx::remove_cancelled_outputsonly forExportError::Cancelled. Every other error returned with the files in place, and a panic inexport_withskipped the cleanup entirely, althoughCx::createhad already recorded every path the export opened (overflow paths included).What changed (
crates/exportonly):remove_cancelled_outputsis nowremove_written_outputs, used for every non-success. Same list, same rule that a file already gone is fine; it returns the first file it could not remove instead of building the error itself.export_asyncruns it on anyErr, before the render log is written. The caller gets the export's own error with its variant unchanged; a file that could not be removed is appended (…; cannot remove partial output <path>: <why>). A cancel behaves exactly as before, including itscannot remove cancelled outputi/o error.RemoveOutputs, besideRenderEnd, removes the files when the export panics, and the panic continues to the caller. It also fires when the export's future is dropped before it finishes; in the browser outputs go through a sink, which records nothing, so that changes nothing there.Test.
render_settings::failed_or_panicked_export_removes_only_files_it_opened(crates/export/tests/it) runs three exports into a folder with decoy files and a folder sitting where frame 20 of the sequence wants to go:ExportError::Io, and no frames remain;Each time the decoys, the blocking folder and (for the failure) the render log are all that is left. I saw each case fail without its part of the fix: with the source change stashed, the failed sequence left frames 0–29; with only the guard disarmed, the panicked sequence left frames 0–9 and the panicked movie left
clip.mp4.cancelled_export_removes_only_files_it_openedpasses unchanged.Not tested: the message for a removal that fails (a read-only folder; that is platform-specific to set up and the text is one
format!you can check by reading), and the issue's Render Queue integration case (a later item failing leaves an earlier item's files). The Render Queue runs each item as its ownexport, whose list holds only that item's files.Verification. On macOS (aarch64) only:
cargo fmt -p effectcraft-export --check,cargo clippy -p effectcraft-export --all-targets -- -D warnings(clean),cargo test -p effectcraft-export(48 unit and 130 integration tests pass, 6 ignored as onmain). The fullcargo xtask cidid not run; I rely on upstream CI for the other crates and for Windows.Summary by CodeRabbit