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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions