jsona
jsona copied to clipboard
RangeError: Maximum call stack size exceeded with jsona 1.10.1 not on older releases
For a decoupled Drupal project we use next-drupal node.js module in combination with next Drupal module. Next-drupal uses jsona for deserialazation. Next-drupal 1.5 (latest release) bundles jsona 1.10.1.
With this version some of our pages give errors like these:
error RangeError: Maximum call stack size exceeded at JsonPropertiesMapper.setAttributes (/node_modules/next-drupal/node_modules/jsona/lib/simplePropertyMappers.js:79:61) at JsonDeserializer.buildModelByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:56:25) at JsonDeserializer.buildRelationsByData (//node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:94:46) at JsonDeserializer.buildModelByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:67:38) at JsonDeserializer.buildRelationsByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:94:46) at JsonDeserializer.buildModelByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:67:38) at JsonDeserializer.buildRelationsByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:89:53) at JsonDeserializer.buildModelByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:67:38) at JsonDeserializer.buildRelationsByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:94:46) at JsonDeserializer.buildModelByData (/node_modules/next-drupal/node_modules/jsona/lib/builders/JsonDeserializer.js:67:38)
Before next-drupal did not bundle jsona with its node.js module and we used jsona 1.9.7. If I simply downgrade jsona to 1.9.7 within the next-drupal folder the error is gone and the page in question loads just fine.
Regression is related to the change made in commit 29b9597164164c46124d135faca9ecc43c7c92fe. Cache for relationships with a meta attribute are skipped due to this condition, which breaks circular references.
The issue can be reproduced with the following data:
{
"data": {
"type": "model",
"id": "1",
"relationships": {
"simpleRelation": {
"data": {
"type": "subModel",
"id": "1",
"meta": {
"foo": "bar"
}
}
}
}
},
"included": [
{
"type": "subModel",
"id": "1",
"relationships": {
"circularRelation": {
"data": {
"type": "model",
"id": "1",
"meta": {
"foo": "bar"
}
}
}
}
}
]
}
Fixed in version 1.11.0
Please check and reopen issue if necessary