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.
https://github.com/discourse/discourse/blob/main/app/assets/javascripts/admin/addon/components/tags-uploader.js#L22-L26
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
https://github.com/discourse/discourse/pull/16383/files#diff-34546f91be45fb6bb745e39a35038cd5875a047bc37cbd267e4c5cfba169f83aR251-R265
https://github.com/discourse/discourse/pull/18393/files#diff-34546f91be45fb6bb745e39a35038cd5875a047bc37cbd267e4c5cfba169f83a
tags-upload.js
https://github.com/discourse/discourse/pull/18292/files#diff-a4dc7755f41639b3d0bfceaca433e948683daf16bee1776f2830e5bc0e49f122
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. ![]()
