BigPizzaV3/CodexPlusPlus · error · anyhow::Error
native menu localizer threw
Error message
native menu localizer threw: {exception} What it means
try_install_native_menu_localizer evaluates a JavaScript localizer in the native menu context via the inspector (CDP). If the evaluation result contains exceptionDetails, the injected script threw, and the raw exception JSON is surfaced as the error message. This indicates the localization script itself failed at runtime inside the native menu environment.
Solutions
- Read the exceptionDetails in the message (it includes exception text and stack) to identify the failing script line.
- Ensure the menu/webview context is fully loaded before installing the localizer (retry after target ready).
- Update the localizer script to match the current native menu DOM/API of the app version.
- Verify inspector_port and target_type point at the correct menu target, then retry.
Example fix
// before
install_native_menu_localizer(port).await?; // throws if script throws
// after
match install_native_menu_localizer(port).await {
Ok(()) => {},
Err(e) => { log::warn!("localizer failed, retrying after load: {e}");
wait_for_menu_ready(port).await?;
install_native_menu_localizer(port).await?; }
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check: ensure the inspector target is reachable before evaluating let reachable = tcp_connect(inspector_port).is_ok();
Try / catch
match install_native_menu_localizer(port).await {
Ok(()) => {},
Err(e) if e.to_string().starts_with("native menu localizer threw") => {
diagnostic_log("localizer_exception", &e.to_string());
// fall back to default (unlocalized) menu
}
Err(e) => return Err(e),
} Prevention
- Keep the localizer script in sync with the app's native menu structure
- Wait for the menu target/context to be ready before evaluating
- Log exceptionDetails with stack for every failure
- Pin the script version to the app version it was written for
- Test the localizer against each supported app version in CI
When it happens
Trigger: Calling install_native_menu_localizer when the evaluated script throws — e.g. the menu DOM/bridge shape differs from what the script expects, the context isn't ready, or a referenced API is undefined in that runtime.
Common situations: App version changed the native menu structure so the localizer's selectors/APIs no longer exist; evaluating too early before the menu context loads; inspector port pointing at the wrong target type.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- native menu localization failed
- Message without an ID requires a stable fallback ID
- periodic Runtime.evaluate reported unavailable capability
- Runtime.evaluate raised an exception
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/7b01b52d68606817.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/native_menu.rs:197
.web_socket_debugger_url
.as_deref()
.is_some_and(|url| !url.is_empty())
})
})
.context("No Electron main-process inspector target found")?;
let websocket_url = target
.web_socket_debugger_url
.as_deref()
.context("selected inspector target has no websocket URL")?;
let script = native_menu_localizer_script()?;
let result = crate::bridge::evaluate_script_with_await_promise(websocket_url, &script, true)
.await
.context("failed to evaluate native menu localizer")?;
if let Some(exception) = result
.get("result")
.and_then(|value| value.get("exceptionDetails"))
{
bail!("native menu localizer threw: {exception}");
}
let _ = crate::diagnostic_log::append_diagnostic_log(
"native_menu.localization_installed",
json!({
"inspector_port": inspector_port,
"target_type": target.target_type,
"target_title": target.title,
"result": result
}),
);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]View on GitHub (pinned to b1ed92e5e4)