Skip to content

Commit

Permalink
Fixes failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akolson committed Sep 30, 2024
1 parent 962a7e3 commit 9a2afbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ describe('contentNode actions', () => {
jest
.spyOn(ContentNode, 'fetchModel')
.mockImplementation(() => Promise.resolve(contentNodeDatum));
jest
.spyOn(ContentNode, 'getAncestors')
.mockImplementation(() => Promise.resolve([contentNodeDatum]));
return ContentNode._add({ title: 'notatest', parent: newId, lft: 2 }).then(() => {
store = storeFactory({
modules: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,10 @@ export const ContentNode = new TreeResource({
* @return {Promise<void>}
*/
async updateAncestors({ id, includeSelf = false, ignoreChanges = false }, updateCallback) {
// getAncestors contains interactions with non-Dexie APIs, so we need to call it from outside
// the transaction as this isn't recommended and is a major cause of transaction related errors.
// Read more here: https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError
// getAncestors invokes a non-Dexie API, so it must be called outside the transaction.
// Invoking it within a transaction can lead to transaction-related issues, including premature
// commit errors, which are a common problem when mixing non-Dexie API calls with transactions.
// See: https://dexie.org/docs/DexieErrors/Dexie.PrematureCommitError
const ancestors = await this.getAncestors(id);

return await this.transaction({ mode: 'rw' }, async () => {
Expand Down

0 comments on commit 9a2afbb

Please sign in to comment.