{"record":{"id":"7f367d3103875665","repo":"oxc-project/oxc","slug":"effect-callbacks-are-synchronous-to-prevent-race-c","errorCode":null,"errorMessage":"Effect callbacks are synchronous to prevent race conditions.","messagePattern":"Effect callbacks are synchronous to prevent race conditions\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/exhaustive_deps.rs","lineNumber":70,"sourceCode":"    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} does nothing when called with only one argument.\"\n    ))\n    .with_label(span)\n    .with_help(\"Did you forget to pass an array of dependencies?\")\n    .with_error_code_scope(SCOPE)\n}\n\nfn unknown_dependencies_diagnostic(hook_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"React Hook {hook_name} received a function whose dependencies are unknown.\"\n    ))\n    .with_help(\"Pass an inline function instead.\")\n    .with_label(span)\n    .with_error_code_scope(SCOPE)\n}\n\nfn async_effect_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Effect callbacks are synchronous to prevent race conditions.\")\n        .with_label(span)\n        .with_help(\"Consider putting the asynchronous code inside a function and calling it from the effect.\")\n        .with_error_code_scope(SCOPE)\n}\n\nfn missing_dependency_diagnostic(\n    hook_name: &str,\n    deps: &[Name<'_>],\n    span: Span,\n    mutable_ref_dependency: Option<&str>,\n) -> OxcDiagnostic {\n    let single = deps.len() == 1;\n    let deps_pretty = if single {\n        format!(\"'{}'\", deps[0])\n    } else {\n        let mut iter = deps.iter();\n        let all_but_last = iter.by_ref().take(deps.len() - 1).map(|s| format!(\"'{s}'\")).join(\", \");\n        let last = iter.next().unwrap();","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/react/exhaustive_deps.rs#L52-L88","documentation":"Raised by react/exhaustive-deps when an effect callback is declared async (returns a Promise). React expects effects to be synchronous; async effects cause race conditions because cleanup cannot cancel pending promises.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/exhaustive_deps.rs:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the async work into an inner function and await it inside the synchronous effect body.","Handle cleanup/cancellation explicitly (e.g. via an ignore flag or AbortController)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1f902a69625cd14e6d8dc58feca94da099d2d251","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}