jsona icon indicating copy to clipboard operation
jsona copied to clipboard

RangeError: Maximum call stack size exceeded with jsona 1.10.1 not on older releases

Open beertje44 opened this issue 3 years ago • 1 comments

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.

beertje44 avatar Sep 21 '22 12:09 beertje44

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"
            }
          }
        }
      }
    }
  ]
}

r1kkert avatar Sep 23 '22 09:09 r1kkert

Fixed in version 1.11.0 Please check and reopen issue if necessary

olosegres avatar Nov 22 '22 19:11 olosegres