[GH-ISSUE #20] storage-custom.js:1142 Assertion failed: Merging child values can only be done if existing and current values are both an array or object #19

Closed
opened 2026-05-23 08:25:44 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @appy-one on GitHub (Mar 11, 2021).
Original GitHub issue: https://github.com/appy-one/acebase/issues/20

Originally assigned to: @appy-one on GitHub.

I got this assertion failure in CustomStorage.getNode(). It was trying to merge a standalone string value (stored in its own record because of its size) with the parent object, which also has an (old, shorter) string value stored inline. Apparently in some cases, if a large string is saved in its own record, it is not removed when the value is overwritten by a shorter string (being stored in its parent record) - causing 2 versions being saved and clashing in getNode.

This problem occurs in CustomStorage classes, which is used for IndexedDB and LocalStorage in the browser. Normal AceBase databases are not affected.

To reproduce, run in the browser:

const { AceBase } = require('acebase');
const db = AceBase.WithIndexedDB('test');
db.ready(async () => {
   await db.ref('test').set({ str: 'Large string value that will be stored in its own record because it has more than 50 chars' });
   await db.ref('test').set({ str: 'Short string' }); // will be saved in parent record
   const test = await db.ref('test').get(); // <-- assertion failure
});

I've found the code causing this issue, fix is on its way.

Originally created by @appy-one on GitHub (Mar 11, 2021). Original GitHub issue: https://github.com/appy-one/acebase/issues/20 Originally assigned to: @appy-one on GitHub. I got this assertion failure in ```CustomStorage.getNode()```. It was trying to merge a standalone string value (stored in its own record because of its size) with the parent object, which also has an (old, shorter) string value stored inline. Apparently in some cases, if a large string is saved in its own record, it is not removed when the value is overwritten by a shorter string (being stored in its parent record) - causing 2 versions being saved and clashing in ```getNode```. This problem occurs in ```CustomStorage``` classes, which is used for IndexedDB and LocalStorage in the browser. Normal AceBase databases are not affected. To reproduce, run in the browser: ```js const { AceBase } = require('acebase'); const db = AceBase.WithIndexedDB('test'); db.ready(async () => { await db.ref('test').set({ str: 'Large string value that will be stored in its own record because it has more than 50 chars' }); await db.ref('test').set({ str: 'Short string' }); // will be saved in parent record const test = await db.ref('test').get(); // <-- assertion failure }); ``` I've found the code causing this issue, fix is on its way.
gitea-mirror 2026-05-23 08:25:44 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@appy-one commented on GitHub (Mar 11, 2021):

Issue was introduced in v1.1.3 while improving IndexedDB performance for #10
Fix published with v1.2.3 - Nodes that cannot be merged in getNode will now be ignored, only printing a console error. Once the node is updated again, the db should be ok again and the error should disappear.

<!-- gh-comment-id:796695456 --> @appy-one commented on GitHub (Mar 11, 2021): Issue was introduced in v1.1.3 while improving IndexedDB performance for #10 Fix published with v1.2.3 - Nodes that cannot be merged in ```getNode``` will now be ignored, only printing a console error. Once the node is updated again, the db should be ok again and the error should disappear.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#19
No description provided.