-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
Improve DX for methods that use all memory #2695
Comments
The inputs are valid for faker, but they hit constraints of the underlying engine. Any suggestion how to handle that? What if the memory limit is increased? Previously, we limited the size arbitrarily (2 ** 20), but this also results in freeze like delays (6f977f6). I have ideas how to make it 4-7 times faster without loosing much randomness, but generating these long strings (or arrays) still takes a long time.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length We could limit the size again to like 2^25 to avoid the runtime limits:
In both scenarios we would limit the user arbritarly, even if their engine supports bigger values. Just catching the out of memory error isn't an option either, because we would have to do that for every method then. We could add a hint like
Could you explain why that would be better or for what purpose do you need bigInt support? |
Sorry, admittedly...I misunderstood the usage of these options and made an assumption that "length" + "min" and "max" would generate a string between those numbers. It's a little misleading at first glance, to be fair. I actually came here to delete this report and submit another to tend to the fact that it causes you to run out of memory. I think that's the crux of the issue here - it should handle it better and have some sort of safe limit - or even a reasonable, safe default with a configurable limit to allow you to blow your foot off, should you choose. My bad for not reading the doc closely enough and making an assumption - bad form. However, I was testing this within the context of the |
We had hoped that a link to the method generating a number would solve that issue.
Do you have a suggestion on how to improve this?
Even if we limit it to 2^20, then you are still limited to ~1k of those strings on the heap. Less if we limit it to 2^25 etc.
I understand how frustrating this can be. Sadly node does a very poor job, logging where the OOM error occurred. For the future, I would like to recommend binary search for the error location or some kind of debug logging, so it is easier to detect where the code halts. The issue was first about |
"The number or range of digits to generate." is perhaps a little hard to read Maybe "The length of the generated string. Should either be a fixed length, or a min and max length. |
FFR: This needs a decision regarding introducing a configurable limit on data (string,array,...) length. |
I think the issue is that if a user passes Do we think its more likely
How about, if a very large length is provided, we log a warning like:
|
Team Decision
|
I plan to tackle this soon.
function methodForBigData(options: { length: NumberOrRange, bypassSafety?: true})
faker.module.methodForBigData({ length: 1_000_000, bypassSafety: true });
// vs
faker.bypassSafety = true;
faker.module.methodForBigData({ length: 1_000_000 });
or
Partially blocked by #3216 |
Team Decision We will not add an We will try to improve the performance of methods generating strings though. |
Pre-Checks
Describe the bug
Using a big integer as min or max in
faker.string.numeric
in length options, is not handled gracefully and causesJavascript heap out of memory
crash in V8. It should at least validate the inputs and provide a graceful exception message. Even better; provide big int support in options.Minimal reproduction code
Additional Context
No response
Environment Info
Which module system do you use?
Used Package Manager
npm
The text was updated successfully, but these errors were encountered: