Skip to content

Commit d88dc29

Browse files
authored
fix(core): prevent race condition in document store (#551)
1 parent d8a7968 commit d88dc29

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/core/src/document/documentStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ const _getDocumentState = bindActionByDataset(
189189
const draft = documentStates[draftId]?.local
190190
const published = documentStates[publishedId]?.local
191191

192+
// wait for draft and published to be loaded before returning a value
193+
if (draft === undefined || published === undefined) return undefined
192194
const document = draft ?? published
193-
if (document === undefined) return undefined
194195
if (path) return jsonMatch(document, path).at(0)?.value
195196
return document
196197
},

0 commit comments

Comments
 (0)