Skip to content

fix(shellBridge): Invalid URL causes unhandled rejection in openExternal #1766

@kaizhou-lab

Description

@kaizhou-lab

Problem

shell.openExternal(url) in shellBridge.ts throws an unhandled promise rejection when called with an invalid URL string. This is reported as ELECTRON-6Z on Sentry with 635 occurrences.

Error: Error: Invalid URL
Culprit: shellBridge.ts:21shell.openExternal(url)
Mechanism: auto.node.onunhandledrejection

Root Cause

The openExternal IPC provider passes the URL directly to Electron's shell.openExternal() without validation. When the renderer sends a malformed URL string, shell.openExternal throws TypeError: Invalid URL.

Fix

Add URL validation using new URL(url) before calling shell.openExternal. Invalid URLs are logged via console.warn and the promise resolves gracefully. Applied to both:

  • shellBridge.ts (Electron mode)
  • shellBridgeStandalone.ts (Node.js standalone mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions