fix: potential race condition on app load when migration (#2977)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
Peng Xiao
2023-07-03 17:40:02 +08:00
committed by GitHub
parent ee2ab4086f
commit 901fc87716
3 changed files with 11 additions and 8 deletions

View File

@@ -118,7 +118,10 @@ const rootWorkspacesMetadataPromiseAtom = atom<
}
// migration step, only data in `METADATA_STORAGE_KEY` will be migrated
if (metadata.some(meta => !('version' in meta))) {
if (
metadata.some(meta => !('version' in meta)) &&
!globalThis.$migrationDone
) {
await new Promise<void>((resolve, reject) => {
signal.addEventListener('abort', () => reject(), { once: true });
window.addEventListener('migration-done', () => resolve(), {