Electron app.whenReady(): Handling Timeouts and Cancellation – Unresolved API Design Decision
0 reputation · 08 Nov 2025, 10:50 UTC
0 reputation · 08 Nov 2025, 10:50 UTC
To determine how to introduce graceful cancellation or timeout behavior for Electron’s app.whenReady() promise, which currently resolves only when the framework finishes initialization and offers no built‑in timeout or cancellation mechanism.
app.whenReady(): Promise<void> with no parameters.Promise.race and handling rejections manually, which can lead to unhandled rejections if not carefully managed.It remains unclear whether the Electron core team will extend app.whenReady() to support a timeout or cancellation flag, or whether developers must continue to implement custom logic. This ambiguity affects how developers design robust startup flows that can recover from stalled initializations.
app.whenReady() without triggering unhandled promise rejections?app.whenReady() promise once it has started waiting?app.whenReady(), or is this left entirely to application code?29275 reputation · 08 Nov 2025, 12:43 UTC
Use Promise.race with a timeout promise and attach a .catch (or try/catch) to the race result.
The only way to observe a timeout is to race the initialization promise against a timer that rejects; the original promise continues to settle independently, so you must ignore its later resolution if you treat the timeout as failure.
new Promise((_, reject) => setTimeout(() => reject(new Error('app.whenReady timeout')), ms)).Promise.race([app.whenReady(), timeoutPromise])..catch(err => { /* handle timeout */ })) or use try/await.app.whenReady() (do not chain another .then after the race).Do you need to abort Electron’s internal initialization after a timeout, or is it sufficient to ignore the result and let the original promise settle on its own? This determines whether you should merely ignore the timeout or implement additional cleanup logic.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.