nut.js
nut.js copied to clipboard
Big Sur Segmentation Fault when retrieving window title
Version Node v17.0.1 nut.js v2.0.1
Short overview Trying to retrieve title of any window results in Seg Fault and no other information, program ends immediately.
Issue occurs on
- [ ] Virtual machine
- [ ] Docker container
- [x] Dev/Host system
Detailed error description Seg fault is occurring on Big Sur any time I attempt to find a window title, either through getWindows or getActiveWindow.
Steps to reproduce error Run this script:
import { getActiveWindow } from '@nut-tree/nut-js';
(async () => {
const window = await getActiveWindow();
const title = await window.title;
console.log(title);
})();
Expected Result:
Terminal
Actual Result:
zsh: segmentation fault node index.js
Observation: Reproducibly segfaults when executed in Terminal.app
, no matter which window is currently active. Runs fine in e.g. iTerm
, though
Edit: This was due to my setup. Reproducibly segfaults in any terminal
This issue is stale because it has been open for 30 days with no activity.
Still open
I also see this error regardless of the terminal used. Tried in iTerm and got the same error.
This issue is stale because it has been open for 30 days with no activity.
Can confirm this issue is happening on Mac M1 using Terminal and iTerm for accessing window titles.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.

Status update:
This issue had me banging my head for several months now. I might have finally tracked down the root cause 💪
Still WIP
Great to hear. Liking the lib so far.
Root cause: Reading the kCGWindowName
property requires an application to be given Screen Recording
permissions. If this is not the case, it'll just return nil
which caused the segfault.
Fixed in release 2.3.0
that just went live.
Yay!