-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uppy.upload()
does not work with XHRUploader
#5669
Comments
Hi @bdirito thanks for the detailed description of the issue , was able to succesfully reproduce it , just a small question , even after trying |
Hi, I'm kind of okay with using
This ties into a bigger problem of not being able to deterministically know which state Uppy is in. Instead of a quickfix, I'm thinking to turn Uppy into a finite state machine with states like This doesn't have to be a major undertaking at first, it could be a new property on Uppy's state and just switching that internally. |
@qxprakash The docs do not actually say what the return value of Looking at the typescript defs (
That's incidentally the same definition as
Note that the If you are asking me what I think the returns of
Regardless of choice the important thing is documentation. @Murderlon Even if you implement a 'getState' api call I think I would like to see 'stateless'
Having said that, having stateful api calls such as |
@qxprakash I was going a bit too fast;
Again I would prefer if the two apis worked and behaved the 'same way' meaning that |
Hi @bdirito I got this working with a few workarounds , I don't think my solution is sustainable but atleast I got to to learn a lot about upyy's state management Here's a video showcasing the exact expected outcome which you described in the issue, I was trying to host this stackblitz but ran into few errors with yarn there while setting that up uppy_bug_fix.mp4So let's start with the first issue which was On 'first' upload(): Everything that is 'expected' happens except the promise does not resolve now this was due to couple of reasons firstly
uppy/packages/@uppy/core/src/Uppy.ts Lines 1612 to 1629 in f877dac
uppy/packages/@uppy/core/src/Uppy.ts Lines 845 to 866 in f877dac
uppy/packages/@uppy/core/src/Uppy.ts Lines 1588 to 1610 in f877dac
so TLDR adding file to newError object before passing it to uppy/packages/@uppy/xhr-upload/src/index.ts Lines 263 to 282 in f877dac
you can see here after catching the error and emitting the 'upload-error' event , it's again throwing error again on line open to feedback about this feel free to correct me if I'm missing anything here. @Murderlon @bdirito @Murderlon I will submit a draft PR for this where we can continue our discussion furthur now moving on to the second issue. |
Second Issue : In second 'second upload()':
It is linked to how uppy considers the state of files with failed uploads , after clicking on upload first time , when it fails and promise gets resolved with failed file state this is what it looks like
and when you click on upload again it doesn't get's added to waitingFileIDs array uppy/packages/@uppy/core/src/Uppy.ts Lines 2298 to 2304 in f877dac
due to this
and eventually and returns because there are no files to upload and the loader keeps on spinning uppy/packages/@uppy/xhr-upload/src/index.ts Lines 497 to 501 in f877dac
for this to work ideally as you described in the issue , after the upload gets failed the first time , the selected file should be treated like as a new file (progress state has to be reset) , upload should start and fail with resolved promise and failed file arrays, that's the workaround I tried to get this work , I reset the progress and error , but I think this violates how uppy considers the state of the files , that's why I got few failing tests :( , would be happy to discuss on this , there are quite a few ways we can take to fix this. |
Initial checklist
Link to runnable example
https://stackblitz.com/edit/vitejs-vite-6cja6cft?file=main.js,index.html
Steps to reproduce
Go to the linked stackblitz
Open console.
Add a single file to the dashboard to upload
Click the
upload()
button to invokeuppy.upload()
The upload is expected to fail (the POST url is bad)
Click the
upload()
button to invokeuppy.upload()
again for the second timeExpected behavior
On both (or any) button press of
upload()
the following should happen:upload()
promise response should resolve and have oneresponse.failed
elementActual behavior
On 'first'
upload()
:On second 'second
upload()
':successful
andfailed
are empty arraysThere are likely several things going on here but at least one aspect seems to be in https://github.com/transloadit/uppy/blob/main/packages/%40uppy/xhr-upload/src/index.ts starting on line 497
Workaround:
I am using
to alternatively call
retryAll()
instead ofupload()
.The ugliness here is that checking state in this way is based on digging into the internal uppy state; I do not know how I am 'supposed' to check what api call I should be making. The ideal situation is that there would be one api call that I could make in both cases. I also tried
retryAll()
as the 'do everything' api call but it does not work unless anupload()
has been called first.The text was updated successfully, but these errors were encountered: