[GH-ISSUE #239] TypeError when trying to add new records after removing old ones #109

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

Originally created by @darkjedi9922 on GitHub (Aug 7, 2023).
Original GitHub issue: https://github.com/appy-one/acebase/issues/239

Originally assigned to: @appy-one on GitHub.

Hello. I face a problem with following scenario:

  1. Add a "large" dataset to some collection, using update. I have noticed that it starts to reproduce from around 110 records. If set it to much less, the problem does not happen for some reason
  2. Remove all that records with a query
  3. Try to add a new "small" dataset (around 5-10 records), using update, and this fails with a TypeError somewhere in the binary tree:
S:\Projects\debug\acebase\dist\cjs\btree\binary-tree.js:1642
        const lastKey = lastEntry.key;
                                  ^
TypeError: Cannot read properties of undefined (reading 'key')
    at BinaryBPlusTree._findAll (S:\Projects\debug\acebase\dist\cjs\btree\binary-tree.js:1642:35)
    at async BinaryBPlusTree._threadSafe (S:\Projects\debug\acebase\dist\cjs\btree\binary-tree.js:942:26)
    at async createStreamFromBinaryTree (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:2666:33)
    at async _mergeNode (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:3160:5)
    at async Object.write [as _customWriteFunction] (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:1945:28)
    at async AceBaseStorage._updateNode (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:1957:26)
    at async AceBaseStorage.updateNode (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:1891:27)
    at async LocalApi.update (S:\Projects\debug\acebase\dist\cjs\api-local.js:70:24)
    at async DataReference.update (S:\Projects\debug\acebase\node_modules\acebase-core\dist\cjs\data-reference.js:232:36)
    at async S:\Projects\debug\acebase\spec\custom-test.js:25:5

Node.js v18.15.0

In order to help to debug it, I prepared a test for this scenario, where the problem is reproduced stably: https://github.com/darkjedi9922/acebase-bug-reproduce/blob/bug-reproduce/spec/custom-test.js
Run the test with node .\spec\custom-test.js

Originally created by @darkjedi9922 on GitHub (Aug 7, 2023). Original GitHub issue: https://github.com/appy-one/acebase/issues/239 Originally assigned to: @appy-one on GitHub. Hello. I face a problem with following scenario: 1. Add a "large" dataset to some collection, using `update`. I have noticed that it starts to reproduce from around 110 records. If set it to much less, the problem does not happen for some reason 2. Remove all that records with a query 3. Try to add a new "small" dataset (around 5-10 records), using `update`, and this fails with a TypeError somewhere in the binary tree: ``` S:\Projects\debug\acebase\dist\cjs\btree\binary-tree.js:1642 const lastKey = lastEntry.key; ^ TypeError: Cannot read properties of undefined (reading 'key') at BinaryBPlusTree._findAll (S:\Projects\debug\acebase\dist\cjs\btree\binary-tree.js:1642:35) at async BinaryBPlusTree._threadSafe (S:\Projects\debug\acebase\dist\cjs\btree\binary-tree.js:942:26) at async createStreamFromBinaryTree (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:2666:33) at async _mergeNode (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:3160:5) at async Object.write [as _customWriteFunction] (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:1945:28) at async AceBaseStorage._updateNode (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:1957:26) at async AceBaseStorage.updateNode (S:\Projects\debug\acebase\dist\cjs\storage\binary\index.js:1891:27) at async LocalApi.update (S:\Projects\debug\acebase\dist\cjs\api-local.js:70:24) at async DataReference.update (S:\Projects\debug\acebase\node_modules\acebase-core\dist\cjs\data-reference.js:232:36) at async S:\Projects\debug\acebase\spec\custom-test.js:25:5 Node.js v18.15.0 ``` In order to help to debug it, I prepared a test for this scenario, where the problem is reproduced stably: https://github.com/darkjedi9922/acebase-bug-reproduce/blob/bug-reproduce/spec/custom-test.js Run the test with `node .\spec\custom-test.js`
gitea-mirror 2026-05-23 08:31:00 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@appy-one commented on GitHub (Aug 16, 2023):

Hi @darkjedi9922 I published a fix for this in v1.29.3, thanks for reporting and providing unit testing code!

Do you like AceBase? 👇🏼

Sponsor AceBase Spread the word contribute

<!-- gh-comment-id:1681304385 --> @appy-one commented on GitHub (Aug 16, 2023): Hi @darkjedi9922 I published a fix for this in v1.29.3, thanks for reporting and providing unit testing code! Do you like AceBase? 👇🏼 [![Sponsor AceBase](https://user-images.githubusercontent.com/26569719/168233053-8e56b243-4140-40ab-9a30-4cb3cc149bfe.svg)](https://github.com/sponsors/appy-one) [![Spread the word](https://user-images.githubusercontent.com/26569719/169265089-3d593555-e1ad-4390-986b-877ac2c38a47.svg)](https://twitter.com/intent/tweet?button=&url=https://github.com/appy-one/acebase&text=I'm+using+@AcebaseRealtime+in+my+project+to+make+my+life+easier!&button=) [![contribute](https://user-images.githubusercontent.com/26569719/169265318-30c4c6a5-7c89-46a0-a7a2-ef433a8192f4.svg)](https://github.com/appy-one/acebase#contributing)
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#109
No description provided.