From 8f5ce9d610bd0bd2accac01064c0ba71a8897ca4 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 24 Feb 2022 11:16:56 -0800 Subject: [PATCH] (core) Wait for transform column before finalizing Summary: This adds a new private field to ColumnTransform that settles when the transform column is done preparing. Finalize then waits for this promise before proceeding. A bug was occurring when the prepare promise was still pending, but finalize was triggered indirectly, causing finalize to throw an error due to the transform column not yet existing. Test Plan: Tested manually. Reviewers: jarek, dsagal Reviewed By: jarek, dsagal Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3288 --- app/client/models/DocData.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/client/models/DocData.ts b/app/client/models/DocData.ts index 6b0de018..afc339e2 100644 --- a/app/client/models/DocData.ts +++ b/app/client/models/DocData.ts @@ -109,7 +109,9 @@ export class DocData extends BaseDocData { prepareResolve(options.prepare()); this._shouldIncludeInBundle = options.shouldIncludeInBundle; - await triggerFinalizePromise; + // If finalize is triggered, we must wait for preparePromise to fulfill before proceeding. + await Promise.all([triggerFinalizePromise, preparePromise]); + // Unset _shouldIncludeInBundle so that actions sent by finalize() are included in the // bundle. If they were checked and incorrectly failed the check, we'd have a deadlock. // TODO The downside is that when sending multiple unrelated actions quickly, the first