Skip to content

TypeError when trying to add new records after removing old ones #239

Closed
@darkjedi9922

Description

@darkjedi9922

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions