systeminformation icon indicating copy to clipboard operation
systeminformation copied to clipboard

Use asynchronous operations everywhere to avoid blocking the main thread

Open dcodeIO opened this issue 1 year ago • 6 comments

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!

dcodeIO avatar Nov 22 '24 09:11 dcodeIO

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 🙏

lukechilds avatar Nov 23 '24 05:11 lukechilds

@sebhildebrandt would you be able to include this in the next release?

Spartan-Hex-Shadow avatar Dec 11 '24 20:12 Spartan-Hex-Shadow

@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 avatar Dec 11 '24 21:12 sebhildebrandt

@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.

sylt avatar Dec 19 '24 13:12 sylt

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.

dcodeIO avatar Jan 13 '25 16:01 dcodeIO

@sebhildebrandt can we get this merged as an incremental v5 release?

Spartan-Hex-Shadow avatar Jan 16 '25 18:01 Spartan-Hex-Shadow