`setTimeoutMicros` doesn't appear to work in the latest versions of `web-tree-sitter`
alexr00 opened this issue · comments
Alex Ross commented
Problem
The last version where setTimeoutMicros
works in the web-tree-sitter
package is 0.22.2
. I've tested with version 0.22.3
-0.22.6
and none of them seem to respect the timeout set by setTimeoutMicros
Steps to reproduce
Here's an example. When I run it with 0.22.2
, I can see that several rounds are run (for my sample source
it's 19), but newer versions I only see 1 round get run.
Parser.init().then(async () => {
const parser = new Parser();
const ts = await Parser.Language.load('./src/tree-sitter-typescript.wasm');
parser.setLanguage(ts);
parser.setTimeoutMicros(50000);
let error = true;
let timeoutTree;
let rounds = 0;
while (error) {
rounds++;
try {
timeoutTree = parser.parse(source);
if (timeoutTree) {
error = false;
}
} catch (e) {
// expected because we've set a timeout that will be hit
}
}
console.log('rounds:', rounds);
});
Expected behavior
The timeout set with setTimeoutMicros
is respected.
Tree-sitter version (tree-sitter --version)
0.22.6
Operating system/version
Windows 11
ObserverOfTime commented
Is this also an issue in Node or Rust?
Alex Ross commented
The node bindings are on version 0.21.1
, which I tested and it worked as expected (setTimeoutMicros
is respected).