From 87d5c0826519d78cabbda9dc80d75df60a479e77 Mon Sep 17 00:00:00 2001 From: Christian Hartmann Date: Mon, 16 Mar 2026 22:31:31 +0100 Subject: [PATCH] fix: prevent race conditions while creating options Signed-off-by: Christian Hartmann --- src/components/Questions/AnswerInput.vue | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/Questions/AnswerInput.vue b/src/components/Questions/AnswerInput.vue index a32318a8f..f37fbf758 100644 --- a/src/components/Questions/AnswerInput.vue +++ b/src/components/Questions/AnswerInput.vue @@ -278,16 +278,24 @@ export default { const answer = { ...this.answer } answer.text = value - // Dispatched for creation. Marked as synced - this.$set(this.answer, 'local', false) - const newAnswer = await this.createAnswer(answer) + // Prevent any queued debounced PATCHes from running while creating + this.queue.pause() + try { + // Dispatched for creation. Marked as synced + this.$set(this.answer, 'local', false) + const newAnswer = await this.createAnswer(answer) - // Forward changes, but use current answer.text to avoid erasing - // any in-between changes while creating the answer - newAnswer.text = this.$refs.input.value - this.localText = '' + // Forward changes, but use current answer.text to avoid erasing + // any in-between changes while creating the answer + newAnswer.text = this.$refs.input.value + this.localText = '' - this.$emit('create-answer', this.index, newAnswer) + this.$emit('create-answer', this.index, newAnswer) + } finally { + // Clear pending update tasks (stale PATCHes) before resuming processing + this.queue.clear() + this.queue.start() + } }, /**