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

Maximum call stack size exceeded #40

Closed
KordonDev opened this issue Jan 27, 2017 · 5 comments
Closed

Maximum call stack size exceeded #40

KordonDev opened this issue Jan 27, 2017 · 5 comments
Labels
Milestone

Comments

@KordonDev
Copy link

I have to use the null as value in mutations. Therefore I cloned the repository and packaged it.

Now in parse.js line 488 in the function parseValueLiteral accepts null as value. But when I use it in the browser i get the error:

RangeError: Maximum call stack size exceeded
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:77:19)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)
    at stripLoc (https://localhost:9000/lib/graphql-tag/browser.js:105:26)

To use Graphql-tag in the browser I used browserify (browserify index.js --standalone graphqlTag -o=browser.js).

In my file line 77 is:function stripLoc (doc, removeLocAtThisLevel) {.

Line 105 is

if (valueType === '[object Object]' || valueType === '[object Array]') {
     doc[keys[key]] = stripLoc(value, true);
}

in function stripLoc.

@jnwng jnwng added the bug label Jan 31, 2017
@jnwng
Copy link
Contributor

jnwng commented Jan 31, 2017

@KordonDev would it be possible to include the gql document that is triggering this? we shouldn't need a schema or anything, just the text that is getting parsed by graphql-tag.

@jnwng
Copy link
Contributor

jnwng commented Jan 31, 2017

looks like this may be related: #6

@KordonDev
Copy link
Author

KordonDev commented Feb 1, 2017

I posted the library in a gist you can find here. To generate the file I cloned the repository and transpiled it with the newest versions of the libraries in package.json.

My query looks like this

gql`
query {
    opportunities {
        name
    }
}
`

For this short query the function stripLoc will be called multiple thousand times before it crashes. Chrome achieves 7000+ calls, Firefox even 40000+.

@KordonDev
Copy link
Author

KordonDev commented Feb 1, 2017

Further investigation got me to the point that I noticed that with the now graphql version, the property loc has to new properties startToken and endToken. Both are of the type Tok. Tok has the properties next and previous which point to another Tok with these two properties. This is the point where the infinite loop appears.

My workaround is to store the properties startToken and endToken in local variables and attach it after the for loop again.

I will make an pull request where you can see the problem.

Now I get the error in apollo-client, I will look for that later.

@jnwng
Copy link
Contributor

jnwng commented Feb 28, 2017

this should be resolved as part of graphql-tag@v1.3.0

@jnwng jnwng closed this as completed Feb 28, 2017
jesseschalken added a commit to jesseschalken/apollo-codegen that referenced this issue Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants