Skip to content

Fix stuck WorkBench attachment import#7798

Open
acwhite211 wants to merge 3 commits intomainfrom
issue-7794
Open

Fix stuck WorkBench attachment import#7798
acwhite211 wants to merge 3 commits intomainfrom
issue-7794

Conversation

@acwhite211
Copy link
Member

@acwhite211 acwhite211 commented Mar 9, 2026

Fixes #7794

Identified and fixed two issues with the WB upload attachments.

The main issue was that the Upload promise could hang forever. uploadFile() used XMLHttpRequest but only listened to readystatechange. 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 into uploadFiles(...).

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-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list

Testing instructions

  • Go to workbench
  • Click on import attachments
  • Select attachments to import
  • See it doesn't get stuck on uploading, and that it continues to the 'Select a Base Table with Attachments' dialog.
  • See that POST network request were made to the asset server, and that they were successful.
image image image

@acwhite211 acwhite211 marked this pull request as ready for review March 10, 2026 06:16
@acwhite211 acwhite211 requested review from a team, CarolineDenis and alesan99 March 10, 2026 06:16
@acwhite211
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Cannot import attachments in WB

1 participant