Fix #53: Illegal Invocation in jest tests
Fix #53
This fixes the illegal invocation. Basically, the problem described in https://stackoverflow.com/questions/9677985/uncaught-typeerror-illegal-invocation-in-chrome is what is happening here, but it appears to be a race condition.
When we re-load the context in the same process (which happens with Jest's worker pool), the getter is triggered, for no apparent reason, BEFORE the native extension has had a chance to load. this is actually the user-land object, with no knowledge of the native prototype yet. Just by changing the name of the extension's getters, it fixes this race condition.
I've added Jest and 3 simple jest tests, all of which failed before the change (you're welcome to try them against master to see what I mean)
@maxbrunsfeld
Hi! Can we expect this fix to get merged?
@maxbrunsfeld seriously, can you take a look sometime? thank you.
screw it. clearly unmaintained.
No reason to not leave it open
@cellog could you fix the merge conflict/update the PR please?
Also, doesn't this also need to be done for Parser.prototype?
https://github.com/tree-sitter/node-tree-sitter/blob/661155300243bfc5e3194fc38417df9306403330/index.js#L255
@cellog Could you please fix the PR so it can get merged?
I am not a maintainer of tree-sitter, and do not have the time or energy to update this PR. You're welcome to re-create it if you need it.
Any update here? We encounter the same issue. Thank you.