Small error in the console after a successful CSV file upload for tags

If you upload a CSV file with tags, the console will display an error after a successful upload.


Here is some digging.

The underlying issue is essentially that the modal closes too fast with the current logic.

The error happens in uppy-upload.js.
The properties failed to be set because the element (uppy-upload) was already destroyed.

How is it possible? this._uppyInstance?.cancelAll();

For reference, _reset is called from _allUploadsComplete.

On successful upload, this is the order of functions:
uploadDone_allUploadsComplete → [ _reset]

When uploadDone is called, the modal is closed right away.
This means that the uppy-upload element will be destroyed at the end of the frame.

Back to this._uppyInstance?.cancelAll();. This will trigger the event below.
That’s the reason why it fails. Because of run(), the properties will be set after the element is destroyed.

This is a minor regression. Introduced here:

uppy-upload.js

tags-upload.js

Possible working solutions:

  • Closing the modal a little later
  uploadDone() {
    this.refresh();
    this.dialog
      .alert(I18n.t("tagging.upload_successful"))
      .finally(() => this.closeModal());
  }
  • Moving the check out of the run() loop.
    this._uppyInstance.on("file-removed", (file, reason) => {
      // we handle the cancel-all event specifically, so no need
      // to do anything here. this event is also fired when some files
      // are handled by an upload handler
      if (reason === "cancel-all") {
        return;
      }

      run(() => {

I’m not sure if there is a better solution. So, I’m posting here.
That’s a lot of text for a non-blocking minor issue, but it was not initially evident. :smile:

3 Likes