Repository navigation
Conversation
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟡 Changes recommended
The lifecycle documentation incorrectly promises mutually exclusive terminal callbacks and misstates the onUploadComplete arguments, which could cause parents to process an upload attempt’s termination twice.
1 open issue
What changed in this PR
This PR lets parents identify which file failed or was dismissed in UploadInputV4, improving per-file upload tracking.
Changes:
- Pass the original
Fileas the fourth argument toonError. - Call
onRemove(file)when dismissing an upload error, excluding files rejected before upload. - Add regression tests for file identity and dismissal callbacks, and document callback behavior.
| File | Description |
|---|---|
src/components/inputs/upload-input-v4/index.js |
Adds file-aware error and dismissal callbacks and lifecycle documentation. |
src/components/inputs/upload-input-v4/__tests__/upload-input-v4.test.js |
Tests failed-file identity and dismissal behavior for uploaded and rejected files. |
Review effort: Balanced
| * Every File reported through `onUploadStart` is later reported once through | ||
| * `onUploadComplete`, `onError(err, status, id, file)` or `onRemove(file)`, and a | ||
| * retry starts it again. Dismissing its error row calls `onRemove`, so a parent can | ||
| * track exactly which files are running or failed. |
There was a problem hiding this comment.
@tomrndom Agreed, and the fix should go one step further: onUploadComplete still does not say which File finished, so a parent cannot track exactly which files are running, which is what this doc block promises.
Completion is reported as (body, id, data), so the CFP form has to match the finished upload by original_name and size (isSameFile in call-for-presentations #106). Uppy builds the file id with lastModified (generateFileID in @uppy/utils), so two different files with the same name and size can upload in the same input, and the form can then drop the wrong running entry: the same stale-entry case this PR is meant to close. And as noted above, a failed file is reported twice (onError, then onRemove when its row is dismissed), so "reported once" does not hold either.
Suggested fix: pass the File on completion too. It only adds an argument, so Contract A (onUploadComplete(response, id, data) in sds/direct-to-storage-uploads-uppy-s3-multipart.md) stays intact:
// handleDelivered
if (callback) callback(body, inputId, { media_type: type, media_upload: current }, file.data);and describe what actually happens:
* Each attempt of a File reported through `onUploadStart` ends in
* `onUploadComplete(body, id, data, file)` or `onError(err, status, id, file)`, unless
* its row is deleted first, which reports `onRemove(file)`. Deleting a delivered row or
* dismissing an error row also reports `onRemove(file)`, and a retry reports
* `onUploadStart` again.A test that runs retry, fail again and dismiss, and checks the callback sequence, would pin this contract down.

ref: https://app.clickup.com/t/9014802374/86bd1y0qx
this is based on the comments from fntechgit/call-for-presentations#106 (comment)
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit