fix: initIndex exception handling and error-message typos#364
Closed
andreinknv wants to merge 2 commits into
Closed
fix: initIndex exception handling and error-message typos#364andreinknv wants to merge 2 commits into
andreinknv wants to merge 2 commits into
Conversation
initIndex (both classes) caught only std::bad_alloc around the index
constructor, but hnswlib signals allocation failure with
std::runtime_error ("Not enough memory"). An out-of-memory initIndex
therefore let a C++ exception escape the N-API method and abort the
process. Widen the handler to std::exception so it surfaces as a
thrown JavaScript Error.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two argument-validation error strings were misspelled: the named argument is reported as `allowRepalceDeleted` (the real name is `allowReplaceDeleted`) and the positional check says "sencond" instead of "second". Neither string is asserted by the test suite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two issues in
initIndex:initIndex(both classes) catches onlystd::bad_allocaround the index constructor, but hnswlib signalsallocation failure with
std::runtime_error("Not enough memory").An out-of-memory
initIndextherefore lets a C++ exception escape theN-API method and abort the process.
validator reports
allowRepalceDeleted(the real argument isallowReplaceDeleted), and the positional validator says"sencond"instead of
"second".Fix
Widen the
initIndexhandlers tostd::exceptionso an hnswliballocation failure surfaces as a thrown JavaScript
Error, and correctthe two misspellings. Neither error string is asserted by the test
suite.
Verification
npm test— 100/100 passing; native addon builds clean.🤖 Generated with Claude Code