sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.65k stars 300 forks source link

Persistent PowerShell Issue with systeminformation Module #907

Open narmatha291289 opened 2 months ago

narmatha291289 commented 2 months ago

Issue Description:

I'm encountering an issue while working with persistent PowerShell in the systeminformation module. When I call si.getStaticData() immediately after initializing the PowerShell, it works as expected. However, if I call it after some other si functions, it doesn't return the expected output. Execution halts thereafter.

Code Snippet:

javascript

const si = require("systeminformation");

async function fetchData() {

    try {
        await si.powerShellStart();

        const staticData = await si.getStaticData();
        console.log("Static Data:", JSON.stringify(staticData));

        const osInfo = await si.osInfo();
        console.log("OS Info:", JSON.stringify(osInfo));

        const systemInfo = await si.system();
        console.log("System Info:", JSON.stringify(systemInfo));

        const staticData_1 = await si.getStaticData();
        console.log("Static Data-1:", JSON.stringify(staticData_1));

        return { staticData, osInfo, systemInfo, staticData_1 };

    } catch (error) {

        console.error("Error fetching data:", error);
        return null;
    }
}

fetchData();

Issue Details:

After investigating, I found that si.getStaticData() behaves inconsistently. It returns the output correctly when called immediately after initializing the PowerShell, but not when called after other si functions.

Steps to Reproduce:

  1. Initialize the PowerShell with si.powerShellStart().
  2. Call si.getStaticData() after some other si functions, such as si.osInfo() and si.system().
  3. Note that si.getStaticData() does not return the expected output.

Expected Behavior:

I expect si.getStaticData() to return the correct output regardless of its position in the code and after other si function calls.

Additional Information:

Environment: Windows 10; Node - v18.20.2; PowerShell - v5.1.19041.4170 systeminformation version: 5.22.5

Any guidance on resolving this issue would be greatly appreciated. If I've overlooked any mistakes or if there's additional information needed, please let me know. Thank you for your assistance!

narmatha291289 commented 2 months ago

@sebhildebrandt , I would greatly appreciate any guidance on resolving this issue. It would be very helpful for me. If I've missed any errors or if additional information is needed, please let me know. Thank you for your assistance!