From d94f3801410cd47bbaa93a630c8f4e11ee08e1dc Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 12 Dec 2021 18:56:32 -0500 Subject: [PATCH] API: Fix race conditions in `setText`, `appendText`, `restoreRevision` --- CHANGELOG.md | 2 ++ src/node/db/API.js | 18 ++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d044260d..14653a33c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ * Fixed a potential attribute pool corruption bug with `copyPadWithoutHistory`. * Mappings created by the `createGroupIfNotExistsFor` HTTP API are now removed from the database when the group is deleted. +* Fixed race conditions in the `setText`, `appendText`, and `restoreRevision` + functions (HTTP API). #### For plugin authors diff --git a/src/node/db/API.js b/src/node/db/API.js index 49d6b9cef..040abf5a6 100644 --- a/src/node/db/API.js +++ b/src/node/db/API.js @@ -201,10 +201,8 @@ exports.setText = async (padID, text) => { // get the pad const pad = await getPadSafe(padID, true); - await Promise.all([ - pad.setText(text), - padMessageHandler.updatePadClients(pad), - ]); + await pad.setText(text); + await padMessageHandler.updatePadClients(pad); }; /** @@ -223,10 +221,8 @@ exports.appendText = async (padID, text) => { } const pad = await getPadSafe(padID, true); - await Promise.all([ - pad.appendText(text), - padMessageHandler.updatePadClients(pad), - ]); + await pad.appendText(text); + await padMessageHandler.updatePadClients(pad); }; /** @@ -559,10 +555,8 @@ exports.restoreRevision = async (padID, rev) => { const changeset = builder.toString(); - await Promise.all([ - pad.appendRevision(changeset), - padMessageHandler.updatePadClients(pad), - ]); + await pad.appendRevision(changeset); + await padMessageHandler.updatePadClients(pad); }; /**