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

setTimeoutMicros doesn't appear to work in the latest versions of web-tree-sitter #3341

Closed
alexr00 opened this issue May 6, 2024 · 2 comments · Fixed by #3372
Closed

setTimeoutMicros doesn't appear to work in the latest versions of web-tree-sitter #3341

alexr00 opened this issue May 6, 2024 · 2 comments · Fixed by #3372

Comments

@alexr00
Copy link

alexr00 commented May 6, 2024

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

@alexr00 alexr00 added the bug label May 6, 2024
@alexr00 alexr00 changed the title setTimeoutMicros doesn't appear to work in the latest versions setTimeoutMicros doesn't appear to work in the latest versions of web-tree-sitter May 6, 2024
@ObserverOfTime
Copy link
Member

Is this also an issue in Node or Rust?

@alexr00
Copy link
Author

alexr00 commented May 6, 2024

The node bindings are on version 0.21.1, which I tested and it worked as expected (setTimeoutMicros is respected).

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

Successfully merging a pull request may close this issue.

2 participants