Skip to content

Fix stuck WorkBench attachment import#7798

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

Fix stuck WorkBench attachment import#7798
acwhite211 wants to merge 7 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.


After some follow up, it seems that the batch attachment upload is also having a similar issue as the WB attachment upload. The problem is that when uploading in batch attachments, the loading is hanging as well.

Found an issue where the collectionPreferences.use(...) function was being called within uploadFileWrapped(...). This was causing an issue

The solution was to move the hook call into the component scope and pass the value down as a plain argument.

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.
  • Go to attachments and click "Import" and create a new batch attachment import.
  • Select attachments to import and select a field, like catalog number for example.
  • Click on "Save" and then "Upload"
  • See that the upload loading bar completes and doesn't stall.
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.

@acwhite211 acwhite211 marked this pull request as draft March 10, 2026 14:13
@acwhite211
Copy link
Member Author

acwhite211 commented Mar 10, 2026

Looks like WB asset import is working, but there also seems to be a similar issue with the batch attachment upload where it is stilling hanging. Investigating... hold off on review for now.

@acwhite211
Copy link
Member Author

Ok, fixed the batch attachment upload issue as well and added to the testing instructions. Good to review now.

@acwhite211 acwhite211 marked this pull request as ready for review March 10, 2026 16:08
@acwhite211 acwhite211 requested a review from emenslin March 10, 2026 16:32
Copy link
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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.
  • See that the upload loading bar completes and doesn't stall.

After importing attachments in WB, selecting a base table, and then adding any fields, when trying to validate the fields are not getting validated.

03-10_11.46.mp4

@github-project-automation github-project-automation bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Mar 10, 2026
Copy link
Collaborator

@bhumikaguptaa bhumikaguptaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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.
  • See that the upload loading bar completes and doesn't stall.
Image

looks good to me, I am able to upload attachments via workbench and batch upload.
When I try to validate, except when the cell formatting is incorrect, when trying to validate the fields are not getting validated.
https://kufishv720260114-issue-7794.test.specifysystems.org/specify/workbench/19/

@acwhite211
Copy link
Member Author

@emenslin @bhumikaguptaa Thanks, I'll check out the validation issue.

@acwhite211
Copy link
Member Author

acwhite211 commented Mar 10, 2026

Made some code changes to get the attachments validation results to appear in the WB dataset table UI view. Might need to do some extra testing to make sure all the validation results are correct.

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

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

Cannot import attachments in WB

3 participants