libnyanpasu/clash-nyanpasu · error

{:?}

Error message

{:?}

What it means

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.

Source

Thrown at backend/tauri/src/enhance/script/js.rs:276

                    result
                        .as_string()
                        .ok_or_else(|| JsNativeError::typ().with_message("Expected string"))
                        .map(|str| str.to_std_string_escaped()),
                    take_console_logs()
                );
                let mapping = wrap_result!(
                    serde_json::from_str(&result)
                        .map_err(|e| { std::io::Error::new(std::io::ErrorKind::InvalidData, e) }),
                    take_console_logs()
                );
                (Ok::<Mapping, JsRunnerError>(mapping), take_console_logs())
            };
            let (res, logs) = wrapped_fn();
            match res {
                Ok(mapping) => (Ok(mapping), logs),
                Err(e) => {
                    tracing::error!("error: {:?}", e);
                    (Err(anyhow::anyhow!("{:?}", e)), logs)
                }
            }
        })
        .await;
        let _ = tokio::fs::remove_file(&path).await;
        match res {
            Ok(output) => output,
            Err(e) => (Err(e.into()), vec![]),
        }
    }
}

mod utils {
    use oxc_allocator::Allocator;
    use oxc_ast_visit::{
        Visit,
        walk::{walk_function, walk_module_export_name},
    };

View on GitHub (pinned to f7dbce2997)

Solutions

  1. Read the {:?} payload in the logs to find the JS-side error message.
  2. Run the script in Node/a browser console to reproduce and fix the runtime error.
  3. Ensure the default export returns a value synchronously or via a resolved Promise.
  4. Fix typos/undefined references; the embedded runtime lacks browser globals.

Example fix

// before
const main = (config) => config.profiles.missingField;
// after
const main = (config) => config?.profiles?.missingField ?? null;
Defensive patterns

Strategy: try-catch

Validate before calling

// caller-side: verify the script is syntactically valid JS before processing
new Function(scriptSource); // throws SyntaxError if invalid

Try / catch

try {
  const result = await process(script);
} catch (e) {
  logger.error('script execution failed', e); // show degraded config, keep original
}

Prevention

When it happens

Trigger: 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.

Common situations: Users write profile enhancement scripts that reference undefined fields, throw on invalid configs, or use globals unsupported by the embedded JS runtime.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08). Data as JSON: /api/errors/4b8b8e14309cf7c0. Report an issue: GitHub.