Closed antelle closed 2 years ago
when i use stopMonitoring() from within plain nodejs (17.1.0) on my Arch linux (systemd), i get:
Assertion 'm' failed at src/libsystemd/sd-device/device-monitor.c:443, function device_monitor_receive_device(). Aborting.
This PR fixes it, allowing me to cleanly quit my program. Please merge and release!
Closing as https://github.com/MadLittleMods/node-usb-detection/pull/162 has merged these changes 🚀
Everyone mentioned in the upcoming 4.14.0 changelog and will be released once I figure out why the GitHub Actions for the Windows builds aren't working, https://github.com/MadLittleMods/node-usb-detection/issues/164
Thanks for the contribution @antelle @umbernhard @Julusian! 🐙
Hi! 👋
Thanks for the library, it's awesome and seems to be much more stable compared to alternatives! 🎉
The library works like this (simplified pseuducode):
When we call
stop
, the devicefd
is destroyed because we destroyudev
handle, however if we're still using thisfd
inpoll
, it causes SIGSEGV in Electron. It doesn't repeat in node.js, no idea why.Simple PoC:
Compile it with:
Result (not always, repeat it several times):
This change moves destroying of the library handle to the callback that's called after "work" is complete.
While this is not critical because
stopMonitoring
must be called before exit, it's better if the app quits correctly instead of crashing.I've tested only a simple case and I assume, this needs a bit more extensive testing.