-
Notifications
You must be signed in to change notification settings - Fork 7
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
FATAL ERROR: Error::New napi_get_last_error_info #132
Comments
This error seems to occur if a variable inside the filter function was deleted. I reproduced this error with the code below: const hnswlib = require('hnswlib-node');
const index = new hnswlib.HierarchicalNSW('l2', 3);
index.initIndex({ maxElements: 4 });
index.addPoint([1, 2, 3], 1)
index.addPoint([4, 5, 6], 2)
index.addPoint([1, 2, 3], 3)
index.addPoint([7, 8, 9], 4)
arr = [1, 2]
const filterFnc = (label) => arr.includes(label);
delete arr;
console.table(index.searchKnn([1, 2, 3], 2, filterFnc)); $ node issue_132.js
FATAL ERROR: Error::New napi_get_last_error_info
1: 0x104dd69f8 node::Abort() [/Users/foo/.anyenv/envs/nodenv/versions/20.3.1/bin/node]
2: 0x104dd6ae4 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/Users/foo/.anyenv/envs/nodenv/versions/20.3.1/bin/node]
3: 0x104da5af4 napi_open_callback_scope [/Users/foo/.anyenv/envs/nodenv/versions/20.3.1/bin/node]
4: 0x11a71dd98 Napi::Error::Error(napi_env__*, napi_value__*) [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
5: 0x11a71d5ec Napi::Error::New(napi_env__*) [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
6: 0x11a72d140 Napi::Value::ToBoolean() const [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
7: 0x11a72d0cc CustomFilterFunctor::operator()(unsigned long) [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
... It is recommended to check if any variables in the filter function have been freed. |
Thanks for that repro! I definitely don't delete any variables directly, I let everything get garbage collected. Furthermore, I experience the issue as soon as I restart my development server (after hours and hours of previous starts/stops). The issue persists for some time (maybe on the order of minutes?), and then resolves itself. |
Update: I figured out the problem, and it was exactly along the lines of what you said. I was creating a Dictionary of Sets
Then, I was iterating through some other items and trying to use this in the filter function:
But if the group hadn't been seen before, then this would throw the error because Thanks for your help. |
Is the HSNW index automatically garbage collected, or is it recommended that we "free" the memory when we're done? I was wondering if something like resizeIndex would work?
I ask because I intermittently get this error:
It's worth noting that I use the
filterFunction
argument quite frequently to see if the index is in some pre-defined set of indices.Thanks!
The text was updated successfully, but these errors were encountered: