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

Clone clause in Index.query loop #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fbennett
Copy link

In a tool that uses lunr.js client-side, and performs searches with a fuzzy query (literal, trailing wildcard, editDistance of 1), lunr.js was crashing (erratically) on iOS browsers with:

ReferenceError: posting is not defined

Digging further, we found that the strings in expandedTerms were somehow being corrupted. Skipping the corrupted items got the system working, but (of course) search results differed on iOS and Linux (we didn't test Windows). Cloning the clause object as in this pull request gets us identical results on the two platforms.

Not sure what's going on there. Maybe the JS engine in iOS does some sort of optimization on objects in a loop.

@olivernn
Copy link
Owner

Thanks for proposing a fix for this. I also see you found the issue with the investigation into what is happening.

Out of interest, do the documents you are indexing contain unicode characters?

As for your change, this may work but I'd also like to understand what, if any, impact it has on performance. I still think that having a smarter trimmer is the right eventual fix, finding time to implement that is tricky for me at the moment though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants