RW v1 Maximum call stack size exceeded

I just upgraded from RW 0.48 to v1.0.1 and when I run yarn rw dev api I get the following error. Has anyone seen it before? Any ideas what to do about it?

api | GraphQL endpoint at /graphql
api | 01:44:49 🌲 Server listening at http://[::]:8911
api | RangeError: Maximum call stack size exceeded
api |     at rewireType (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/@graphql-tools/utils/index.js:2325:24)
api |     at rewireType (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/@graphql-tools/utils/index.js:2331:33)
api |     at rewireType (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/@graphql-tools/utils/index.js:2327:33)
api |     at rewireType (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/@graphql-tools/utils/index.js:2331:33)
api |     at rewireFields (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/@graphql-tools/utils/index.js:2294:38)
api |     at fields (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/@graphql-tools/utils/index.js:2245:31)
api |     at resolveObjMapThunk (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/graphql/type/definition.js:504:40)
api |     at defineFieldMap (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/graphql/type/definition.js:760:20)
api |     at GraphQLObjectType._fields (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/graphql/type/definition.js:685:26)
api |     at GraphQLObjectType.getFields (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/graphql/type/definition.js:704:27)
api |     at collectReferencedTypes (/Users/tobbe/dev/redwood/acm-store-rw/node_modules/graphql/type/schema.js:387:51)

Also tried upgrading to RW 1.2.0 but still seeing the same error. It’s difficult to debug because it happens as soon as the server starts up and it’s not pointing to anything specific in my code.

Have solved similar in the past with

My guess is user error, from the stack you have a loop in your type definitions

Hard to say without seeing the debugger

Have to spend some time trying to fix this now. Can’t stay on v0.48 forever :smiley:

Plus, there are some sweet new features coming out that I want to use!

Something’s changed ever so slightly since I last ran into this error. The error + stacktrace now looks like this

Aug 13 09:27:36 PM  /opt/render/project/src/node_modules/@redwoodjs/graphql-server/node_modules/@graphql-tools/utils/index.js:2297
Aug 13 09:27:36 PM                  field.args = rewireArgs(field.args);
Aug 13 09:27:36 PM                               ^
Aug 13 09:27:36 PM  
Aug 13 09:27:36 PM  RangeError: Maximum call stack size exceeded
Aug 13 09:27:36 PM      at rewireFields (/opt/render/project/src/node_modules/@redwoodjs/graphql-server/node_modules/@graphql-tools/utils/index.js:2297:30)
Aug 13 09:27:36 PM      at fields (/opt/render/project/src/node_modules/@redwoodjs/graphql-server/node_modules/@graphql-tools/utils/index.js:2245:31)
Aug 13 09:27:36 PM      at resolveObjMapThunk (/opt/render/project/src/node_modules/graphql/type/definition.js:504:40)
Aug 13 09:27:36 PM      at defineFieldMap (/opt/render/project/src/node_modules/graphql/type/definition.js:766:20)
Aug 13 09:27:36 PM      at GraphQLObjectType._fields (/opt/render/project/src/node_modules/graphql/type/definition.js:691:26)
Aug 13 09:27:36 PM      at GraphQLObjectType.getFields (/opt/render/project/src/node_modules/graphql/type/definition.js:710:27)
Aug 13 09:27:36 PM      at collectReferencedTypes (/opt/render/project/src/node_modules/graphql/type/schema.js:387:51)
Aug 13 09:27:36 PM      at new GraphQLSchema (/opt/render/project/src/node_modules/graphql/type/schema.js:174:9)
Aug 13 09:27:36 PM      at mapSchema (/opt/render/project/src/node_modules/@redwoodjs/graphql-server/node_modules/@graphql-tools/utils/index.js:2399:12)
Aug 13 09:27:36 PM      at wrapAffectedResolvers (/opt/render/project/src/node_modules/@redwoodjs/graphql-server/dist/plugins/useRedwoodDirective.js:67:31)
Aug 13 09:27:36 PM  error Command failed with exit code 1.

That’s when I try to deploy it. I’ll see if I can reproduce on localhost

Any luck? Are you running api/web separately? Is this happening when web starts?

FWIW, I checked out v.48.0, and installed the test-project from it, I could run the api but not the web side. After I ran yarn rw upgrade and brought it up to 2.2.0, everything seemed to boot up fine.

I did not get your same error.

I can’t reproduce it locally, only when I deploy. I’m deploying to Render right now, because I need something serverful

Yes, Render is running them separately. It’s the api side that crashes.
Render will try to restart it when it crashes, but as soon as it comes back up it crashes again

Got RW up to v2.2.0.
Bad news: Still getting the “maximum callstack size exceeded” error
Good news: I can reproduce on my own machine

Inside /node_modules/graphql/type/schema.js I can see it lists all of the types, queries and mutations. When I tried adding in a console.log into my SDL queries, mutations and types I can clearly see it gets stuck in an infinite loop printing field names…

Finally figured it out!

I had graphql caching configured. As soon as I removed that things started working again. Next step is finding a fix to make it work with caching. (I’m deploying in a serverful environment, so was using InMemoryCache)

1 Like

Updating to the latest version and updating how it’s configured to match and everything is back working :partying_face:

1 Like