BigPizzaV3/CodexPlusPlus · error · anyhow::Error
No injectable page target found
Error message
No injectable page target found
What it means
Thrown by `pick_page_target` when, after preferring a Codex-matching page target, no injectable page-type CDP target with a webSocketDebuggerUrl exists in the target list. Only `type == "page"` targets with a non-empty webSocketDebuggerUrl are injectable.
Solutions
- Open a tab/window in the target browser before calling, or navigate an existing one to a real page
- Re-fetch targets via `list_targets` — a previously empty list may now include pages
- Check the targets you pass: filter for `type == "page"` with a non-empty `webSocketDebuggerUrl` to debug why nothing qualifies
- If the browser is headless/minimized with zero pages, launch with an initial about:blank page
Example fix
// before
let targets = cdp::list_targets(9222).await?; // browser freshly started, no pages
let target = cdp::pick_page_target(&targets)?;
// after
let targets = cdp::list_targets(9222).await?;
if targets.iter().all(|t| t.target_type != "page") {
open_new_tab(9222).await?; // e.g. PUT /json/new
}
let targets = cdp::list_targets(9222).await?;
let target = cdp::pick_page_target(&targets)?; Defensive patterns
Strategy: fallback
Validate before calling
fn has_injectable_page(targets: &[CdpTarget]) -> bool {
targets.iter().any(|t| t.target_type == "page" && !t.web_socket_debugger_url.is_empty())
} Try / catch
let target = cdp::pick_page_target(&targets)
.or_else(|_| { open_new_tab(port)?; futures::executor::block_on(cdp::list_targets(port)) })
.and_then(|t| cdp::pick_page_target(&t))?; Prevention
- Ensure at least one tab is open before target selection
- Refresh the target list after browser state changes
- For headless runs, launch with an initial about:blank page
When it happens
Trigger: Calling `pick_page_target` with an empty target slice, a list containing only non-page targets (browser, service_worker, iframe, background_page), or page targets whose webSocketDebuggerUrl is empty/missing.
Common situations: Browser has no tabs open (all windows closed leaving only the browser process), querying during early startup before any page exists, or the browser launched with page targets disabled.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No injectable Codex page target found
- 上游 Base URL 不能为空
- 图片上游 Base URL 不能为空
- browser WebSocket URL has no Browser ID
- browser WebSocket URL has no path
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/55ceaa939c61c8d7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/cdp.rs:252
}
pub fn pick_page_target(targets: &[CdpTarget]) -> anyhow::Result<CdpTarget> {
let mut first_page = None;
for target in targets
.iter()
.filter(|target| is_injectable_page_target(target))
{
first_page.get_or_insert(target);
if is_primary_codex_page_target(target) {
return Ok(target.clone());
}
}
if let Some(target) = first_page {
return Ok(target.clone());
}
bail!("No injectable page target found")
}
pub fn pick_injectable_codex_page_target(targets: &[CdpTarget]) -> anyhow::Result<CdpTarget> {
let priorities: [fn(&CdpTarget) -> bool; 4] = [
is_exact_codex_app_main_target,
is_primary_codex_app_target,
is_chatgpt_desktop_page_target,
is_supported_codex_page_target,
];
for matches_priority in priorities {
if let Some(target) = targets
.iter()
.find(|target| is_injectable_page_target(target) && matches_priority(target))
{
return Ok(target.clone());
}
}
bail!("No injectable Codex page target found")View on GitHub (pinned to b1ed92e5e4)