Use asynchronous operations everywhere to avoid blocking the main thread
This PR removes all blocking operations (child_process.execSync and fs.readSync) from the library and replaces them with asynchronous equivalents while keeping the public API intact.
The diff is intentionally boring, focusing solely on this change and minor related cleanup to minimize the risk of introducing accidental breakage.
Fixes #873. Keep it up!
Just fyi @sebhildebrandt systeminformation causes major performance issues and event loop deadlocks when used in server applications. This PR fixes it.
https://nodejs.org/en/learn/asynchronous-work/dont-block-the-event-loop
We're running this fork at @getumbrel with great results but we'd love to come back to upstream once this is merged 🙏
@sebhildebrandt would you be able to include this in the next release?
@Spartan-Hex-Shadow, @dcodeIO , @lukechilds ... the next major release (6.0) is a complete rewrite (TS) where we do not have any sync functions. This should then be solved.
@sebhildebrandt Even though it is fixed in the next major release in a more rigorous way, perhaps there would be no harm in having it fixed in the current major release? Unless you see any problems with this PR, of course.
Merged master into this branch, so it now includes the fix for https://github.com/sebhildebrandt/systeminformation/security/advisories/GHSA-cvv5-9h9w-qp2m. It appears that one new sync call has been introduced to master since, and it looks like it affects the public API, so all I could reasonably do was add a TODO.
@sebhildebrandt can we get this merged as an incremental v5 release?