Skip to content

fix(media): reset the uploader with cancelAll instead of clear on error - #2064

Open
giladresisi wants to merge 1 commit into
stagingfrom
fix/uploader-clear-during-upload
Open

giladresisi wants to merge 1 commit into
stagingfrom
fix/uploader-clear-during-upload

Conversation

@giladresisi

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

Bug fix (frontend, media uploader). In the Uppy error handler in apps/frontend/src/components/media/new.uploader.tsx, uppy.clear() is replaced with uppy.cancelAll(). Uppy's clear throws whenever an upload is in progress and the installed uploader plugin does not support per-file cancellation, which is the case with @uppy/transloadit; cancelAll removes every file, so each in-flight upload is dropped as a whole instead of shrunk and Uppy does not throw. The rest of the handler (unlock, onEnd, order counter reset) is unchanged.

Why was this change needed?

Sentry CLOUD-S1, Error: The installed uploader plugin does not allow removing files during an upload, has 58 events from 32 users in the last 30 days: 39 on /launches (the post editor's uploader), 18 on /media, 1 on an X connect page.

The handler is meant to reset the uploader after an upload error, but the very condition it runs under (an upload in progress) is the one in which clear throws. So every Transloadit failure during an upload, for example a failed assembly creation, produced a second exception from our own code on top of the original error, and the uploader was left in its half-finished state.

Other information:

Same file as #2063 (the missing-results guard), independent lines; either can merge first.

QA

  1. Run with Transloadit configured, open /media, and from the browser console make assembly creation fail, e.g. wrap window.fetch to reject any URL containing transloadit.com
  2. Add an image through the Upload input
  3. Before this change: besides Uppy's own "Could not create Assembly" log, the console shows Error: The installed uploader plugin does not allow removing files during an upload thrown from new.uploader.tsx
  4. After this change: only Uppy's own assembly log appears, no exception from our code
  5. Restore window.fetch and, without reloading, upload another image: it uploads and appears in the library, showing the uploader recovered

Tested locally exactly as above: step 3 reproduced on the unmodified code earlier in the same session, steps 4 and 5 verified with the change (no exception, the follow-up upload saved and listed).

Checklist:

  • I have read the CONTRIBUTING guide.
  • I have signed the Contributor License Agreement (CLA) (ICLA for individuals, CCLA for entities).
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were no similar issues or PRs already open for this.
  • This PR fixes just ONE issue
  • I have filled in the QA section above with real steps to verify this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_017g3KqiuR5TT68XdqpTRbZh

clear() throws while an upload is in progress with the Transloadit plugin, so every upload error raised a second exception (58 events/30d in prod).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017g3KqiuR5TT68XdqpTRbZh
@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Sep 10, 2026
@strix-security

strix-security Bot commented Sep 10, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for 0f97630.


Reviewed by Strix
Re-run review · Configure security review settings

@postiz-agent

postiz-agent Bot commented Sep 10, 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
Code Security 0 0 0 0 0 issues

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

This branch has not been deployed

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

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant