nut-tree/libnut-core

screen.capture crashes node process on Windows under certain conditions

lewisl9029 opened this issue · 0 comments

Version
2.1.1

Short overview
I've been exploring using nut.js (and more recently the libnut library directly) to control a headless Windows machine monitored through RDP (Using the official Remote Desktop app).

The setup generally worked fine, but I noticed the node process ends up consistently crashing as soon as I disconnect the RDP session. (the script keeps calling screen.capture on a 1 second interval)

Detailed error description
Dug into it a bit this weekend and found that the crash was due to this null returning branch in copyMMBitmapFromDisplayInRect being unhandled downstream.

See #54 for my proposed fix.

Steps to reproduce error

  1. Create a node script that calls setInterval(() => libnut.screen.capture(), 1000)
  2. Run it on a windows machine through RDP
  3. Exit the RDP session
  4. Reconnect to the machine

Expected:
Script is still running

Actual:
Script crashes