-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
Object formating is limitless => Problems with giantic arrays #492
Comments
Ok, after a little bit of investigation i found, that sinon is using formatio for formating. https://github.com/busterjs/formatio Like sinon does with
|
I created a patch for formatio, and I saw that you (@cjohansen) are also a maintainer of formatio, so it will be easy for you to merge my patch (if it's acceptable :). Sinon.JS is missing the config, but it's just replacing
Hope you'll fix this, thank you and kind regards |
Hmm, this shouldn't be closed yet. We still need to use a new formatio version |
Oops, sorry! |
Fix #492 by upgrading formatio and setting a limit
Hey
Using Sinon.JS asertions in browser mode with html formating and a failed assertion (eg calledTwice) causes Sinon to format (to string) all calls to the spied function. Thereby all objects will be formated recoursively. The formater prevents formations of already formated objects -> [circular reference], but it does not prevent the stringification of big arrays.
I'm using Phaser, a game framework. It has an internal array for the Canvas it's painting on. This Uint8ClampedArray has a default size of 1024 * 1024 * 4 = 4194304. I don't know if it's the only array, but the stringification of the array(s) takes more than 1GB of RAM and causes the script to "not respond".
You can't blame a lib to use large arrays, so Sinon.JS must handle this.
Simple example using Phaser to trigger the problem. It will also work if you just create a big array and try to format it:
I'll create a patch and attach it to this issue. I think arrays and object should have a maximum of 100..150 formated properties,
The text was updated successfully, but these errors were encountered: