Open
Conversation
Triggered by 1d502c0 on branch refs/heads/issue-7794
Member
Author
|
I think this solution solves the main issue and is good enough. I added some extra logging on the front-end for asset connection errors. Let me know if you want to add some further abstraction to the code related to the asset server connect from the front-end. |
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.
Fixes #7794
Identified and fixed two issues with the WB upload attachments.
The main issue was that the Upload promise could hang forever.
uploadFile()usedXMLHttpRequestbut only listened toreadystatechange. On network errors, the promise could remain unresolved and the loading UI never closed. This was solved by adding error, abort, and timeout handlers, set an upload timeout, and clean up listeners so the promise always settles.There was another issue with an invalid React hook usage in the legacy WorkBench import-attachments flow.
collectionPreferences.use(...)was called inside a plain helper function 'uploadFiles, not a component/hook. That can throw before upload starts and leave the modal stuck. There was a simple solution to move the hook call into 'FilesPicked' and pass the resolved value intouploadFiles(...).Looking at the network requests, the POST request to the asset server now occur and are successful.
The hook fix in 'WbImportAttachments/index.tsx' removes an invalid React hook call and keeps behavior the same, except it no longer can fail/hang from that mistake.
The XHR fix in 'Attachments/attachments.ts' ensures the upload should complete or fail, never hang forever.
The only new behavior change is the new upload timeout. A very slow upload that takes longer than the timeout will now fail instead of waiting indefinitely.
Checklist
self-explanatory (or properly documented)
Testing instructions