Skip to content

fix(browser): gettabbyid returns undefined when tab not found despite non-nullable return type #8542

Description

Description

Array.prototype.find() returns undefined when no element matches, but the function declares its return type as Promise<TargetInfo> (non-nullable). The as TargetInfo cast silences the compiler but doesn't prevent undefined at runtime. Any caller accessing properties on the result (e.g., tab.url, tab.webSocketDebuggerUrl) will get a TypeError: "Cannot read properties of undefined". This is especially likely during race conditions where a tab closes between getTabs and the caller using the result.

Severity: high
File: src/browser/provider/built-in/dedicated/chrome/cdp-client/utils.ts

Expected Behavior

The code should handle this case properly to avoid unexpected errors or degraded quality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions