fix(uploads): report upload failures instead of reporting success#475
Merged
Conversation
Uploads that failed could be reported as successful, leaving signage media records pointing at uploads that were never committed. There were two independent causes, and fixing either alone would have left a partial fix: - @placeos/cloud-uploads never checked the commit response, so a rejected commit still reported COMPLETED. Fixed in 1.1.2 and picked up here. - addMedia resolved as soon as progress reached 100, which happens before finalisation and the commit run, so a failure afterwards was never seen. It now waits for the upload to actually complete. Credentials: - send the API key in its own header when the session uses one. token() returns the literal string "x-api-key" in that mode, which is not a usable bearer token, so every upload from an API key session was rejected. Retries: - retry a failed upload three times, re-validating credentials between attempts, up from exactly once - retry the media create on 5xx, 408, 429 and transport failures with backoff. 401 is deliberately left to the API client, which already invalidates the token, re-authorises and replays the request. Reporting: - surface the reason an upload failed rather than a generic "Error" - reject with a real Error, and distinguish a cancelled permissions dialog from a genuine failure - handle upload rejections in the image, image list and rich text fields, which previously had none and would surface as unhandled rejections Media library: - build the list from the create response instead of a delayed refetch that lost the new item whenever the backend index lagged the write, which itself read as a failed upload Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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.
Uploads that failed could be reported as successful, leaving signage media records pointing at uploads that were never committed. There were two independent causes, and fixing either alone would have left a partial fix:
Credentials:
Retries:
Reporting:
Media library: