Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
darkjedi9922 opened this issue Aug 7, 2023 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@darkjedi9922
Copy link

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

@appy-one appy-one self-assigned this Aug 16, 2023
@appy-one appy-one added the bug Something isn't working label Aug 16, 2023
appy-one added a commit that referenced this issue Aug 16, 2023
@appy-one
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants