{"record":{"id":"4b8b8e14309cf7c0","repo":"libnyanpasu/clash-nyanpasu","slug":"error-4b8b8e","errorCode":null,"errorMessage":"{:?}","messagePattern":"\\{:\\?\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/enhance/script/js.rs","lineNumber":276,"sourceCode":"                    result\n                        .as_string()\n                        .ok_or_else(|| JsNativeError::typ().with_message(\"Expected string\"))\n                        .map(|str| str.to_std_string_escaped()),\n                    take_console_logs()\n                );\n                let mapping = wrap_result!(\n                    serde_json::from_str(&result)\n                        .map_err(|e| { std::io::Error::new(std::io::ErrorKind::InvalidData, e) }),\n                    take_console_logs()\n                );\n                (Ok::<Mapping, JsRunnerError>(mapping), take_console_logs())\n            };\n            let (res, logs) = wrapped_fn();\n            match res {\n                Ok(mapping) => (Ok(mapping), logs),\n                Err(e) => {\n                    tracing::error!(\"error: {:?}\", e);\n                    (Err(anyhow::anyhow!(\"{:?}\", e)), logs)\n                }\n            }\n        })\n        .await;\n        let _ = tokio::fs::remove_file(&path).await;\n        match res {\n            Ok(output) => output,\n            Err(e) => (Err(e.into()), vec![]),\n        }\n    }\n}\n\nmod utils {\n    use oxc_allocator::Allocator;\n    use oxc_ast_visit::{\n        Visit,\n        walk::{walk_function, walk_module_export_name},\n    };","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/enhance/script/js.rs#L258-L294","documentation":"When a JavaScript enhancement script's wrapped main function returns a rejected promise or throws, process_honey catches it and re-raises it via anyhow, formatting the value with {:?} instead of Display. The error string therefore contains a Rust Debug rendering of the JS error value, which is often hard to read but reflects a runtime failure inside the user's script.","triggerScenarios":"Calling process() on a JS script whose default-exported function throws or returns a rejected Promise, or whose returned value fails the expected mapping conversion.","commonSituations":"Users write profile enhancement scripts that reference undefined fields, throw on invalid configs, or use globals unsupported by the embedded JS runtime.","solutions":["Read the {:?} payload in the logs to find the JS-side error message.","Run the script in Node/a browser console to reproduce and fix the runtime error.","Ensure the default export returns a value synchronously or via a resolved Promise.","Fix typos/undefined references; the embedded runtime lacks browser globals."],"exampleFix":"// before\nconst main = (config) => config.profiles.missingField;\n// after\nconst main = (config) => config?.profiles?.missingField ?? null;","handlingStrategy":"try-catch","validationCode":"// caller-side: verify the script is syntactically valid JS before processing\nnew Function(scriptSource); // throws SyntaxError if invalid","typeGuard":null,"tryCatchPattern":"try {\n  const result = await process(script);\n} catch (e) {\n  logger.error('script execution failed', e); // show degraded config, keep original\n}","preventionTips":["Test enhancement scripts in Node before saving them in the app","Avoid browser-only globals in scripts","Always return a value from the main function","Keep scripts small and defensive with optional chaining"],"tags":["javascript","scripting","runtime-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}