-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: unhandled promise rejection in downloadRemoteBuffer (ELECTRON-77) #1824
Description
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.