{"record":{"id":"723d06e9785f4c69","repo":"facebook/react","slug":"unable-to-acquire-scope-for-the-current-node-this","errorCode":null,"errorMessage":"Unable to acquire scope for the current node. This is a bug in eslint-plugin-react-hooks, please file an issue.","messagePattern":"Unable to acquire scope for the current node\\. This is a bug in eslint-plugin-react-hooks, please file an issue\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts","lineNumber":210,"sourceCode":"          message:\n            `Effect callbacks are synchronous to prevent race conditions. ` +\n            `Put the async function inside:\\n\\n` +\n            'useEffect(() => {\\n' +\n            '  async function fetchData() {\\n' +\n            '    // You can await here\\n' +\n            '    const response = await MyAPI.getData(someId);\\n' +\n            '    // ...\\n' +\n            '  }\\n' +\n            '  fetchData();\\n' +\n            `}, [someId]); // Or [] if effect doesn't need props or state\\n\\n` +\n            'Learn more about data fetching with Hooks: https://react.dev/link/hooks-data-fetching',\n        });\n      }\n\n      // Get the current scope.\n      const scope = scopeManager.acquire(node);\n      if (!scope) {\n        throw new Error(\n          'Unable to acquire scope for the current node. This is a bug in eslint-plugin-react-hooks, please file an issue.',\n        );\n      }\n\n      // Find all our \"pure scopes\". On every re-render of a component these\n      // pure scopes may have changes to the variables declared within. So all\n      // variables used in our reactive hook callback but declared in a pure\n      // scope need to be listed as dependencies of our reactive hook callback.\n      //\n      // According to the rules of React you can't read a mutable value in pure\n      // scope. We can't enforce this in a lint so we trust that all variables\n      // declared outside of pure scope are indeed frozen.\n      const pureScopes = new Set();\n      let componentScope: Scope.Scope | null = null;\n      {\n        let currentScope = scope.upper;\n        while (currentScope) {\n          pureScopes.add(currentScope);","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts#L192-L228","documentation":"The react-hooks/exhaustive-deps rule analyzes each hook callback by asking ESLint's ScopeManager for the variable scope of the callback node (scopeManager.acquire(node)). If the scope manager returns null for a node that must have a scope, the rule cannot compute dependencies and aborts with this invariant error. The message itself states it is a bug in eslint-plugin-react-hooks, not a problem in your code. It almost always indicates a mismatch between the AST a parser produced and what the scope manager can map.","triggerScenarios":"Running ESLint with the exhaustive-deps rule when the configured parser (e.g. @typescript-eslint/parser with unusual parserOptions, or an experimental Babel plugin) emits an AST that leaves a hook callback node without an acquireable scope. Also triggered by other ESLint plugins or custom rules that mutate/replace AST nodes before exhaustive-deps visits them, or by plugin versions that predate a fix for a specific syntax pattern.","commonSituations":"Upgrading eslint-plugin-react-hooks, TypeScript, or @typescript-eslint/* independently so versions drift out of compatibility; monorepos where different packages lint with different parser configs; adopting new syntax (decorators, satisfy expressions, macros) in files containing hooks.","solutions":["Update eslint-plugin-react-hooks to the latest version - several scope-acquisition crashes have been fixed across releases","Align parser tooling: bump or pin @typescript-eslint/parser and eslint to versions known to work with your plugin version (check the plugin's peer dependencies)","Shrink the failure to one file/line by linting files individually, then simplify the offending hook until the trigger syntax is obvious","File an issue on facebook/react with the minimal repro, ESLint config, and package versions - the error message explicitly asks for this","Unblock CI immediately with /* eslint-disable react-hooks/exhaustive-deps */ on that file, and remove it after the real fix"],"exampleFix":"// before (package.json, versions drifted apart)\n\"eslint-plugin-react-hooks\": \"^4.6.0\",\n\"@typescript-eslint/parser\": \"^8.0.0\"\n\n// after (upgrade the plugin, keep the toolchain in lockstep)\n\"eslint-plugin-react-hooks\": \"^5.2.0\",\n\"@typescript-eslint/parser\": \"^8.0.0\"\n// then: npm dedupe && npx eslint --fix-dry-run src/hooks/**","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Only relevant when driving ESLint programmatically (editors, lint runners). Catch the Error, match /Unable to acquire scope for the current node/, and treat it as tooling failure: skip the file with a warning instead of failing the entire lint run, then surface the file for an upgrade/report.","preventionTips":["Keep eslint-plugin-react-hooks, ESLint core, and your parser (babel/@typescript-eslint) on mutually compatible, pinned versions","Verify version pins in CI so a transitive upgrade cannot silently introduce the bug","Lint new or exotic syntax locally before pushing, especially files with hooks","Watch the plugin changelog when adopting new TypeScript syntax"],"tags":["eslint","react-hooks","exhaustive-deps","static-analysis","scope-manager"],"backgroundTag":"eslint-plugin-internal-error","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}