{"record":{"id":"38fa804ae2ffd519","repo":"swc-project/swc","slug":"failed-to-read-program-file","errorCode":null,"errorMessage":"failed to read program file","messagePattern":"failed to read program file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bindings/binding_core_node/src/parse.rs","lineNumber":237,"sourceCode":"            Ok((p, fm))\n        })\n    })\n    .convert_err()?;\n\n    Ok(serialize_program(program, &fm)?)\n}\n\n#[napi]\npub fn parse_file_sync(path: String, opts: Buffer) -> napi::Result<String> {\n    crate::util::init_default_trace_subscriber();\n    let c = get_fresh_compiler();\n    let options: ParseOptions = get_deserialized(&opts)?;\n\n    let (program, fm) = {\n        try_with(c.cm.clone(), false, ErrorFormat::Normal, |handler| {\n            let fm =\n                c.cm.load_file(Path::new(path.as_str()))\n                    .expect(\"failed to read program file\");\n\n            let local_comments = SwcComments::default();\n            let comments = if options.comments {\n                Some(&local_comments as &dyn Comments)\n            } else {\n                None\n            };\n\n            let mut p = c.parse_js(\n                fm.clone(),\n                handler,\n                options.target,\n                options.syntax,\n                options.is_module,\n                comments,\n            )?;\n            p.visit_mut_with(&mut resolver(\n                Mark::new(),","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/bindings/binding_core_node/src/parse.rs#L219-L255","documentation":"Fired in parse_file_sync: `c.cm.load_file(Path::new(path))` failed to read the source file from disk and the code calls `.expect(...)`, panicking with this message. The input at fault is the `path` argument — a nonexistent, unreadable, or otherwise unloadable file path. Because expect() is used, callers receive a panic rather than a structured napi error.","triggerScenarios":"Thrown at bindings/binding_core_node/src/parse.rs:237 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the path exists and the process has read permission before calling parseFileSync","Propagate load_file errors via convert_err/try_with so JS receives a proper error object"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}