(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
This commit is contained in:
George Gevoian 2022-02-24 11:16:56 -08:00
parent 599545fb11
commit 8f5ce9d610

View File

@ -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