Skip to content
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

Graffitti breaks on recursive models (Upgrading from 4.3.3 to 5.0.8) RangeError: Maximum call stack size exceeded #97

Open
jontonsoup opened this issue Mar 1, 2016 · 4 comments

Comments

@jontonsoup
Copy link

When I upgraded from 4.3.3 to 5.0.8 I'm getting an error (RangeError: Maximum call stack size exceeded) in lodash that seems to be related to recursive schemas.

Here is a summary of my model (This worked in 4.3.3):

const RecursiveSchema = new mongoose.Schema({})
RecursiveSchema.add({
  name: {
    type: String,
    required: true,
    match: /^\S+$/
  },
  description: String,
  children: [RecursiveSchema]
})

const mainSchema = new mongoose.Schema({
  fields.....
  recursive: [RecursiveSchema],

}, { timestamps: true })

Here is a stacktrace of the error:

11:07:16 PM web.1  |  /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2309
11:07:16 PM web.1  |      function baseClone(value, isDeep, customizer, key, object, stack) {
11:07:16 PM web.1  |                        ^
11:07:16 PM web.1  |  RangeError: Maximum call stack size exceeded
11:07:16 PM web.1  |      at baseClone (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2309:23)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2358:34
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4127:15
11:07:16 PM web.1  |      at baseForOwn (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2639:24)
11:07:16 PM web.1  |      at baseClone (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2357:39)
11:07:16 PM web.1  |      at baseMergeDeep (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:3175:24)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:3111:11
11:07:16 PM web.1  |      at arrayEach (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:482:11)
11:07:16 PM web.1  |      at baseMerge (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:3104:7)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:11633:7
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4075:13
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:9183:31
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:118:30
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:809:11
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4127:15
11:07:16 PM web.1  |      at baseForOwn (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2639:24)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4096:18
11:07:16 PM web.1  |      at baseReduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:806:5)
11:07:16 PM web.1  |      at reduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8096:14)
11:07:16 PM web.1  |      at extractPaths (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:117:29)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:84:20
11:07:16 PM web.1  |      at arrayReduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:669:21)
11:07:16 PM web.1  |      at reduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8123:14)
11:07:16 PM web.1  |      at extractPath (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:79:34)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:118:39
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:809:11
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4127:15
11:07:16 PM web.1  |      at baseForOwn (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2639:24)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4096:18
11:07:16 PM web.1  |      at baseReduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:806:5)
11:07:16 PM web.1  |      at reduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8096:14)
11:07:16 PM web.1  |      at extractPaths (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:117:29)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:84:20
11:07:16 PM web.1  |      at arrayReduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:669:21)
11:07:16 PM web.1  |      at reduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8123:14)
11:07:16 PM web.1  |      at extractPath (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:79:34)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:118:39
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:809:11
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4127:15
11:07:16 PM web.1  |      at baseForOwn (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2639:24)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4096:18
11:07:16 PM web.1  |      at baseReduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:806:5)
11:07:16 PM web.1  |      at reduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8096:14)
11:07:16 PM web.1  |      at extractPaths (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:117:29)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:84:20
11:07:16 PM web.1  |      at arrayReduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:669:21)
11:07:16 PM web.1  |      at reduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8123:14)
11:07:16 PM web.1  |      at extractPath (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:79:34)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:118:39
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:809:11
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4127:15
11:07:16 PM web.1  |      at baseForOwn (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:2639:24)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:4096:18
11:07:16 PM web.1  |      at baseReduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:806:5)
11:07:16 PM web.1  |      at reduce (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8096:14)
11:07:16 PM web.1  |      at extractPaths (/src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:117:29)
11:07:16 PM web.1  |      at /src/node_modules/@risingstack/graffiti-mongoose/lib/model/model.js:84:20
11:07:16 PM web.1  |      at arrayReduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:669:21)
11:07:16 PM web.1  |      at reduceRight (/src/node_modules/@risingstack/graffiti-mongoose/node_modules/lodash/lodash.js:8123:14)

Here is the diff of my package.json

-    "@risingstack/graffiti": "2.1.2",
-    "@risingstack/graffiti-mongoose": "4.3.3",
+    "@risingstack/graffiti": "3.0.2",
+    "@risingstack/graffiti-mongoose": "5.0.8",
-    "express-graphql": "0.4.5",
+    "express-graphql": "0.4.9",
-    "graphql": "0.4.14",
-    "graphql-relay": "0.3.5",
+    "graphql": "0.4.18",
-    "lodash": "3.10.1",
+    "lodash": "4.5.1",
     "mongoose": "4.3.4",

Any help would be awesome!
Thanks,
Jon

@jontonsoup
Copy link
Author

Confirmed this also happens when bumped to 5.0.

@jontonsoup jontonsoup changed the title Graffitti breaks on revursive models (Upgrading from 4.3.3 to 5.0.8) RangeError: Maximum call stack size exceeded Graffitti breaks on recursive models (Upgrading from 4.3.3 to 5.0.8) RangeError: Maximum call stack size exceeded Mar 1, 2016
@tothandras
Copy link
Contributor

Thanks for the report. I will try to reproduce and fix this.

@tothandras
Copy link
Contributor

I've managed to reproduce the error, although I didn't have a solution just yet. :/

@nodkz
Copy link
Contributor

nodkz commented Mar 29, 2016

Not sure, cause this fix error with mutation objects, which use new introduced code toInputObject few commits ago.

But it can help, if your problem was with mutations. Just try on your project ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants