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

Nondeterministic duplicate variable errors in large files #397

Open
robrix opened this issue Feb 9, 2024 · 0 comments
Open

Nondeterministic duplicate variable errors in large files #397

robrix opened this issue Feb 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@robrix
Copy link
Contributor

robrix commented Feb 9, 2024

JS indexing occasionally logs errors like so:

Analysis error: Error executing node @expr.before_scope at (2316, 3) in stanza at (2279, 1) matching (call_expression) node at (898, 1) and executing node @expr.before_scope at (2316, 3) in stanza at (2279, 1) matching (parenthesized_expression) node at (3114, 7). Caused by: Duplicate variable [syntax node parenthesized_expression (3114, 7)].before_scope for file path: react-router-redux/nextjs-primer/.next/static/development/pages/_app.js

The code in question is about 350KB, and takes roughly 50s to analyze locally on my laptop, making me think it probably times out in prod. I have thus far exclusively encountered this on large files (large enough to time out), tho that could also just be a way of saying "big files have more nodes to which this could happen."

This is, in a word, bogus: two nodes of completely different types in dramatically different parts of the file are nevertheless implicated in the same duplicate variable error. Maybe we're doing some sort of flywheel pattern thing and not cleaning up the allocated nodes' variables correctly before they're reused? (I don't know that we ought to have cleaned up the earlier node by the time we hit the later one at all, mind you.) Or maybe something's getting aliased that shouldn't? Spurious cache hit? Etc.

In this instance both nodes were processed by the same rule, but I'm pretty sure I've seen instances where they only had the variable name in common, not where it was allocated, as well as instances where one or the other node was in a syntactically different enough category that it shouldn't have been encountered by the rule in question at all. (E.g. variable declarations vs. expressions.)

@robrix robrix added the bug Something isn't working label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant