Skip to content

Fix #53: Illegal Invocation in jest tests - #75

Closed
cellog wants to merge 1 commit into
tree-sitter:masterfrom
braze-inc:fix-53-illegal-invocation
Closed

cellog wants to merge 1 commit into
tree-sitter:masterfrom
braze-inc:fix-53-illegal-invocation

Conversation

@cellog

@cellog cellog commented Feb 18, 2021 •

Copy link
Copy Markdown

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

cellog commented Mar 11, 2021

Copy link
Copy Markdown
Author

@maxbrunsfeld

@evheny0

evheny0 commented Jun 4, 2021

Copy link
Copy Markdown

Hi! Can we expect this fix to get merged?

@cellog

cellog commented Jul 26, 2021

Copy link
Copy Markdown
Author

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

@cellog

cellog commented Aug 16, 2021

Copy link
Copy Markdown
Author

screw it. clearly unmaintained.

@cellog cellog closed this Aug 16, 2021
@martaver

Copy link
Copy Markdown

No reason to not leave it open

Comment thread index.js
Comment on lines -363 to -367
nodeText: {
get() {
return this.tree.getText(this)
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Comment thread jest-tests/test.test.js
c.text = tree.getText(node);
return c;
});
} No newline at end of file

@verhovsky verhovsky Jul 17, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing newline pls

Comment thread runit.js
const jsParser = new Parser();
`)
const output = code.rootNode.toString()
console.log(output); No newline at end of file

@verhovsky verhovsky Jul 17, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing newline pls

@verhovsky

Copy link
Copy Markdown
Collaborator

@cellog could you fix the merge conflict/update the PR please?

Also, doesn't this also need to be done for Parser.prototype?

const {parse, setLanguage} = Parser.prototype;

@ilanashapiro

Copy link
Copy Markdown
Contributor

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

@cellog

cellog commented Sep 11, 2023

Copy link
Copy Markdown
Author

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.

@ce-bo

ce-bo commented Jan 31, 2024

Copy link
Copy Markdown

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

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.

"TypeError: illegal invocation" when imported in multiple tests

7 participants