Commit Graph

7 Commits

Author SHA1 Message Date
Wael Nasreddine
5b37140ffa Fix race condition in edit-docs Electron ready event
The edit-docs tool would hang on startup when the Electron 'ready' event
fired before the event listener was registered. This race condition occurred
because:

1. startElectron() creates a deferred promise and registers a 'ready' listener
2. The 'ready' event fires asynchronously at some point during app initialization
3. If async work (like config loading) delays the listener registration,
   Electron may already be ready when app.on('ready', ...) is called
4. Once fired, the 'ready' event doesn't fire again, leaving the listener
   waiting forever

The fix checks electron.app.isReady() before registering the listener:
- If already ready: execute the handler immediately
- If not ready: register the listener as before

This ensures the initialization sequence completes regardless of timing.

The issue became apparent while working on making edit-docs reusable from
other projects (see #8343), where config loading added enough async delay
to consistently trigger the race condition.

Related: https://github.com/TriliumNext/Trilium/issues/8343
2026-01-12 22:08:27 -08:00
Elian Doran
e28794d706 chore(edit-docs): fix typecheck 2025-11-09 19:28:08 +02:00
Elian Doran
970f4b028d chore(server): fix a few more type errors 2025-09-14 10:58:11 +03:00
Elian Doran
1818ae1f72 fix(desktop): blank screen when starting (closes #2103) 2025-06-04 19:55:04 +03:00
Elian Doran
ad0c73d210 feat(edit-docs): read from input directory instead of the zip 2025-05-27 19:24:04 +03:00
Elian Doran
7cb4cc8469 fix(edit-demo): get it to actually start 2025-05-27 19:24:04 +03:00
Elian Doran
6021d33317 chore(edit-docs): split into two entrypoints 2025-05-27 14:03:54 +03:00