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

The value of "val" is out of range #491

Closed
javigualde opened this issue Jan 22, 2024 · 3 comments · Fixed by #496
Closed

The value of "val" is out of range #491

javigualde opened this issue Jan 22, 2024 · 3 comments · Fixed by #496

Comments

@javigualde
Copy link

Hello,

We are having a random issue we can't debug in development, but it's throwing exceptions in production.

The error says:

[ERR_OUT_OF_RANGE]: The value of "val" is out of range. It must be a safe integer greater than 0. Received 0

We attach a screenshoot of all the exception stack trace.

Captura de pantalla 2024-01-22 a las 19 43 26

Someone having the same issue?

Regards.

@metcoder95
Copy link
Member

👋

Hmm, interesting; can you provide an
Minimum Reproducible Example?

@akkerman
Copy link

I got this same error when using an example from the book Multithreaded Javascript.

Versions used:

Node: 16, 18, 19 (20 gives a different error)
Piscina: 4.3.0

Here is the code example:

const Piscina = require('piscina')
const assert = require('node:assert')
const { once } = require('node:events')

if (!Piscina.isWorkerThread) {
  const piscina = new Piscina({
    filename: __filename,
    maxQueue: 'auto'
  });

  (async () => {
    for (let i = 0; i< 10_000_000; i++) {
      if (piscina.queueSize == piscina.options.maxQueue) {
        await once(piscina, 'drain')
      }
      piscina.run(i).then(squareRootOfI => {
        assert.ok(typeof squareRootOfI === 'number')
      })
    }
  })();
}

module.exports = num => Math.sqrt(num)

@metcoder95
Copy link
Member

I was able to reproduce it after some time, it seems that for faster workloads, the difference in nano is 0 causing the histogram go out of bounds.

I'll prepare a fix for it soon

kdy1 pushed a commit to swc-project/pkgs that referenced this issue Dec 2, 2024
While compiling a project using `swc`, I ran into the following issue.
```
 Error  The value of "val" is out of range. It must be >= 1 && <= 9007199254740991. Received 0
```
After digging through, I was able to figure out that the root cause is
the same as piscinajs/piscina#491.
Unfortunately I don't have a repro that I can share, but the issue is
well-documented in the linked issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants