From 0a3009d6ed20a8cf497aac3c656ac2cfbad33ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 20 May 2022 12:18:40 +0200 Subject: [PATCH] Web: fix race condition where job/task update comes in before table is init Tabulator can't handle data changes before it's been initialised. If there is a race condition and a job/task update comes in before that, just ignore the update. It might be better to use Vue's `nextTick()` function to defer the update until Tabulator is ready to receive it, but doing so in a reliable way might be tricky. --- web/app/src/components/JobsTable.vue | 10 ++++++++-- web/app/src/components/TasksTable.vue | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/web/app/src/components/JobsTable.vue b/web/app/src/components/JobsTable.vue index 413145eb..ae1a6cd6 100644 --- a/web/app/src/components/JobsTable.vue +++ b/web/app/src/components/JobsTable.vue @@ -123,11 +123,17 @@ export default { processJobUpdate(jobUpdate) { // updateData() will only overwrite properties that are actually set on // jobUpdate, and leave the rest as-is. - this.tabulator.updateData([jobUpdate]) - .then(this.sortData); + if (this.tabulator.initialized) { + this.tabulator.updateData([jobUpdate]) + .then(this.sortData); + } this._refreshAvailableStatuses(); }, processNewJob(jobUpdate) { + if (this.tabulator.initialized) { + this.tabulator.updateData([jobUpdate]) + .then(this.sortData); + } this.tabulator.addData([jobUpdate]) .then(this.sortData); this._refreshAvailableStatuses(); diff --git a/web/app/src/components/TasksTable.vue b/web/app/src/components/TasksTable.vue index e2edf6a5..b629dc03 100644 --- a/web/app/src/components/TasksTable.vue +++ b/web/app/src/components/TasksTable.vue @@ -128,8 +128,10 @@ export default { processTaskUpdate(taskUpdate) { // updateData() will only overwrite properties that are actually set on // taskUpdate, and leave the rest as-is. - this.tabulator.updateData([taskUpdate]) - .then(this.sortData); + if (this.tabulator.initialized) { + this.tabulator.updateData([taskUpdate]) + .then(this.sortData); + } this._refreshAvailableStatuses(); },