[FIX] Importers progress sending too much update events to clients (#17857)

* Delay reporting the import progress to the frontend so it doesn't overwhelm the connection

* Increased time to 250ms
pull/17860/head
pierre-lehnen-rc 5 years ago committed by GitHub
parent 40efb0a027
commit d70f4afb1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/importer/server/classes/ImporterBase.js

@ -291,9 +291,13 @@ export class Base {
// Or the completed is greater than or equal to the total amount
if (((this.progress.count.completed % 500) === 0) || (this.progress.count.completed >= this.progress.count.total)) {
this.updateRecord({ 'count.completed': this.progress.count.completed });
this.reportProgress();
} else if (!this._reportProgressHandler) {
this._reportProgressHandler = setTimeout(() => {
this.reportProgress();
}, 250);
}
this.reportProgress();
this.logger.log(`${ this.progress.count.completed } messages imported`);
return this.progress;
@ -303,6 +307,10 @@ export class Base {
* Sends an updated progress to the websocket
*/
reportProgress() {
if (this._reportProgressHandler) {
clearTimeout(this._reportProgressHandler);
this._reportProgressHandler = false;
}
ImporterWebsocket.progressUpdated(this.progress);
}

Loading…
Cancel
Save