fix(desktop): guard lazy-loaded native-module calls (fixes focusassist tray crash) #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/focus-assist-lazy-crash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The app loads now (registry.node fixed) but crashed on minimize-to-tray: focusassist.node is not a valid Win32 application. windows-focus-assist loads its .node LAZILY on first getFocusAssist() call, so guarding only the require() (previous fix) let the wrong-arch binary throw at the call site, uncaught. Now the whole call is wrapped + failure cached -> reports not-in-DND instead of crashing. Same hardening for macos-notification-state.
The app still crashed on minimize-to-tray with 'focusassist.node is not a valid Win32 application'. windows-focus-assist loads its .node LAZILY on the first getFocusAssist()/isPriority() call (module lib/index.js: lib = lib || require('bindings')('focusassist')), not at require() time — so the earlier guard around require() passed, and the wrong-arch binary threw at the CALL site (during the tray DND check), uncaught. Wrap the whole getWindowsDoNotDisturb body (require + calls) in try/catch and cache the failure so a broken native module reports 'not in DND' instead of crashing, and isn't retried every check. Same hardening applied to the macos-notification-state call path. registry-js is unaffected (its call sites are already inside try/catch, and its .node is now a correct PE binary). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>