node-tree-sitter icon indicating copy to clipboard operation
node-tree-sitter copied to clipboard

Fix #53: Illegal Invocation in jest tests

Open cellog opened this issue 4 years ago • 9 comments

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)

cellog avatar Feb 18 '21 15:02 cellog

@maxbrunsfeld

cellog avatar Mar 11 '21 14:03 cellog

Hi! Can we expect this fix to get merged?

evheny0 avatar Jun 04 '21 11:06 evheny0

@maxbrunsfeld seriously, can you take a look sometime? thank you.

cellog avatar Jul 26 '21 01:07 cellog

screw it. clearly unmaintained.

cellog avatar Aug 16 '21 12:08 cellog

No reason to not leave it open

martaver avatar Nov 18 '22 15:11 martaver

@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

verhovsky avatar Jul 17 '23 14:07 verhovsky

@cellog Could you please fix the PR so it can get merged?

ilanashapiro avatar Sep 11 '23 18:09 ilanashapiro

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.

cellog avatar Sep 11 '23 19:09 cellog

Any update here? We encounter the same issue. Thank you.

ce-bo avatar Jan 31 '24 10:01 ce-bo