-
Notifications
You must be signed in to change notification settings - Fork 400
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
RangeError: Invalid String Length at JSON.stringify() #422
Comments
This might actually end up being a duplicate of #323 |
Update: I simply commented out the de-duplication measures that happens within the Types look great—nice and succinct. In my case, I have control elsewhere over avoiding duplicates within intersections and unions. Could we create an option that allows for this package to skip that optimization? |
Sorry for the delay! Thanks for the patch, but this is a bug that we should fix, and not something that consumers should be able to bail out of to avoid hitting the bug. Root cause fix, which will be included in the next JSTT release: #447. |
Optimize optimizer to avoid deep JSON serialization (fix #422)
Published as part of v11.0.0. |
Beautiful @bcherny — thank you! |
First off—thank you all very much for the work you do in this package. We're attempting to use it in Payload CMS in an effort to auto-generate types from our users' configs.
We've been working with a proof of concept, testing through a few different projects here and there.
Some Payload configs can be moderately large when converted to a JSON schema: 10-15K lines or so. We're seeing that when configs near that size, compiling JSON to TS with this package just crashes with the following error:
I believe this error comes from JS running out of memory. We have attempted turning off
format
as the docs instruct, but this did not help anything.Here is an example of a decently large JSON schema that is causing the error above.
Looking at the stack trace, line 34 of
optimizer.js
looks to have to do with unions. In the example schema, we have a lot of unions, many generated from a single Payload "field" calledlink
. You can see an example of the JSON schema for alink
field on line 44 of the example above.Is there a potential performance enhancement or bug here?
As it stands we can't compile the schema linked above.
Any ideas?
The text was updated successfully, but these errors were encountered: