Skip to content

Nondeterministic duplicate variable errors in large files #397

Open
@robrix

Description

@robrix

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions