Skip to content

fix: unhandled promise rejection in downloadRemoteBuffer (ELECTRON-77) #1824

@kaizhou-lab

Description

@kaizhou-lab

Problem

Sentry issue ELECTRON-77 — 96 occurrences.

downloadRemoteBuffer in src/process/bridge/fsBridge.ts uses Promise.reject() for URL validation errors (unsupported protocol, disallowed host). When the fetchRemoteImage IPC handler is invoked through the event emitter adapter (src/adapter/main.ts), the emitter does not await the async handler's returned promise, causing Promise.reject() to surface as an unhandled promise rejection (mechanism: auto.node.onunhandledrejection).

Root Cause

Promise.reject() creates a rejected promise object. Even though the caller uses await inside a try-catch, the event emitter path doesn't properly propagate the async result, allowing Node.js to detect the rejection as unhandled.

Fix

Replace Promise.reject(new Error(...)) with throw new Error(...) in downloadRemoteBuffer. Synchronous throws are caught by the caller's try-catch without creating intermediate rejected promise objects.

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