Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception thrown by SystemMonitor #113

Closed
zenwarr opened this issue Mar 9, 2019 · 1 comment
Closed

Unhandled exception thrown by SystemMonitor #113

zenwarr opened this issue Mar 9, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@zenwarr
Copy link

zenwarr commented Mar 9, 2019

Hello! Unfortunately, I've faced a problem when this module runs in some environments (I'm using node 8 LTS).

TypeError: Cannot read property 'length' of undefined
    at SystemMonitor.calcLoad (node_modules/puppeteer-cluster/dist/SystemMonitor.js:35:36)
    at Timeout.interval.setInterval [as _onTimeout] (node_modules/puppeteer-cluster/dist/SystemMonitor.js:23:56)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)

Code that throws the error:

const cpus = os.cpus();
for (let i = 0, len = cpus.length; i < len; i += 1) {
    const cpu = cpus[i];
    for (const type in cpu.times) {
        totalTick += cpu.times[type];
    }
    totalIdle += cpu.times.idle;
}

And the problem is related to the fact that os.cpus can sometimes return undefined: nodejs/node#19022

@thomasdondorf
Copy link
Owner

thomasdondorf commented Mar 9, 2019

Thanks for reporting. This behavior is not even documented in the Node.js docs.

Just pushed a fix, which also improves startup time (by not starting the system monitoring) if the monitoring is disabled.

// edit: Version 0.15.2 is released now (which fixes the issue)

@thomasdondorf thomasdondorf added the bug Something isn't working label May 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants