Add abort signal to upload#373
Conversation
| const encryptFileMock = vi.fn(); | ||
| const uploadFileMock = vi.fn().mockReturnValue(fakeHash); | ||
|
|
||
| try { |
There was a problem hiding this comment.
I've removed this try catch since if the test throws an error (which happen to me) the test already fails and gives a more detailed error.
sg-gs
left a comment
There was a problem hiding this comment.
Shouldn't be the signal parameter optional? Otherwise all the clients are forced to adapt to a parameter that is commonly optional
src/network/index.ts
Outdated
| } | ||
| totalSize += size; | ||
| async startUpload(bucketId: string, fileSize: number, signal: AbortSignal, parts = 1): Promise<StartUploadResponse> { | ||
| if (fileSize < 0) { |
There was a problem hiding this comment.
I was thinking that even <= 0 should be invalid also
There was a problem hiding this comment.
Makes sense, I will change it
| * @param index | ||
| * @param shards | ||
| */ | ||
| private static finishUpload( |
There was a problem hiding this comment.
This function was static to be able to be called finishUpload too, however, I think it's easier to read if we use different names (this one just makes the request), and by making it non static we can acces the client, appDetails and auth directly from this function to make the references more direct.
There was a problem hiding this comment.
I've checked also if any project was using the static version of finishUpload but seems that nothing is using it: https://github.com/search?q=org%3Ainternxt%20finishUpload&type=code.
What
abortSignalto the requests of upload file.asyncandawaitto add the functions to the stack trace. Add abort signal to upload inxt-js#106 (comment)