{"record":{"id":"9ee00d6cb913cb83","repo":"swc-project/swc","slug":"failed-to-load-file","errorCode":null,"errorMessage":"failed to load file","messagePattern":"failed to load file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bindings/binding_core_node/src/transform.rs","lineNumber":270,"sourceCode":"        let c = compiler_for_program_input(&program_input, get_compiler());\n\n        try_with(\n            c.cm.clone(),\n            !options.config.error.filename.into_bool(),\n            error_format,\n            |handler| c.run(|| process_program_input(&c, handler, program_input, &options)),\n        )\n        .convert_err()\n    } else {\n        let c = get_fresh_compiler();\n\n        try_with(\n            c.cm.clone(),\n            !options.config.error.filename.into_bool(),\n            error_format,\n            |handler| {\n                c.run(|| {\n                    let fm = c.cm.load_file(Path::new(&s)).expect(\"failed to load file\");\n                    c.process_js_file(fm, handler, &options)\n                })\n            },\n        )\n        .convert_err()\n    }\n}\n","sourceCodeStart":252,"sourceCodeEnd":278,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/bindings/binding_core_node/src/transform.rs#L252-L278","documentation":"Node binding panic in transform_file_sync: cm.load_file for the requested source path failed inside the try_with closure, and .expect('failed to load file') turned the I/O failure into a process aborting panic rather than a napi error.","triggerScenarios":"Thrown at bindings/binding_core_node/src/transform.rs:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the file path and read permissions before calling transformFileSync","Return the load_file error through the handler so JS gets a catchable error"],"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"}