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

Invariant Violation: Invariant Violation: 44 #19

Closed
balazsorban44 opened this issue Jun 8, 2020 · 5 comments
Closed

Invariant Violation: Invariant Violation: 44 #19

balazsorban44 opened this issue Jun 8, 2020 · 5 comments

Comments

@balazsorban44
Copy link

balazsorban44 commented Jun 8, 2020

Sent to here with the following:
Invariant Violation: Invariant Violation: 44 (see https://github.com/apollographql/invariant-packages)

I have not a single clue what I am supposed to do. I have seen folks using grep like:

grep -r "InvariantError(" node_modules/**/bundle.cjs.js

or

grep -r "InvariantError(" node_modules/**/bundle.esm.js

None of those have a 44.

What does that mean? How should I debug this?

using:

"@apollo/client": "^3.0.0-rc.2",
"@apollo/link-context": "^2.0.0-beta.3",

not sure what else is relevant, cause I don't know the error's origin.

Could someone help with this?

UPDATE: I resolved the issue in my code. The problem was that I used useQuery/useMutation hooks of @apollo/client outside of ApolloProvider.

This does resolves this issue itself, the dev experience was somewhat cumbersome, and my solution was to hunt down the breaking commit, rather than getting a clear message of the possible error.

@cwshevlin
Copy link

I'm currently trying to track down an Invariant Violation: 8 and having the same experience manually searching the code. The text in parenthesis says to visit this repository, but there is not a clear next step once you get here.

@ifndefdeadmau5
Copy link

For me it happened when I have client.readQuery in my code but there's no such a cached query result in my store beforehand

benjamn added a commit to apollographql/apollo-client that referenced this issue Jul 21, 2020
When an invariant fails in production, a cryptic numeric error of the form
`Invariant Violation: 42` is thrown, with a reference to the error codes
section of invariant-packages README.md: https://github.com/apollographql/invariant-packages#error-codes

This vague guidance has not proven adequate in many cases, to say the
least: see apollographql/invariant-packages#18,
apollographql/invariant-packages#19, #6604,

Using error codes instead of error strings remains important for
production bundle sizes, but I think we can make it substantially easier
to look up the error string corresponding to each error code, by
generating a single file containing all the invariant error codes for each
@apollo/client release.

Starting with Apollo Client 3.1.0, this manifest file can be found in
@apollo/client/invariantErrorCodes.js (using an npm/yarn-installed copy of
@apollo/client, since this file is generated in the ./dist directory, not
checked into the repository). The file contains an explanatory comment,
the @apollo/client version, and a sequential map from error numbers to the
{ file, node } responsible for the error.

I wish we could go back and republish old versions of @apollo/client to
include this file, but at least things should be easier going forward.
benjamn added a commit to apollographql/apollo-client that referenced this issue Jul 21, 2020
When an invariant fails in production, a cryptic numeric error of the form
`Invariant Violation: 42` is thrown, with a reference to the error codes
section of invariant-packages README.md: https://github.com/apollographql/invariant-packages#error-codes

This vague guidance has not proven adequate in many cases, to say the
least: see apollographql/invariant-packages#18,
apollographql/invariant-packages#19, #6604,

However, this vague guidance (which was intended to suggest searching
your installed node_modules/@apollo/client package for the error code)
has not proven adequate in many cases, to say the least: see apollographql/invariant-packages#18,
apollographql/invariant-packages#19, #6604, #5730, #5291, and #5975,
to cite just a few of the many issues we've seen since #4521.

Using error codes instead of error strings remains important for
production bundle sizes, but I think we can make it substantially easier
to look up the error string corresponding to each error code, by
generating a single file containing all the invariant error codes for each
@apollo/client release.

Starting with Apollo Client 3.1.0, this manifest file can be found in
@apollo/client/invariantErrorCodes.js (using an npm/yarn-installed copy of
@apollo/client, since this file is generated in the ./dist directory, not
checked into the repository). The file contains an explanatory comment,
the @apollo/client version, and a sequential map from error numbers to the
{ file, node } responsible for the error.
jimrandomh pushed a commit to jimrandomh/apollo-client that referenced this issue Jul 22, 2020
…llographql#6665)

When an invariant fails in production, a cryptic numeric error of the form
`Invariant Violation: 42` is thrown, with a reference to the error codes
section of invariant-packages README.md: https://github.com/apollographql/invariant-packages#error-codes

This vague guidance has not proven adequate in many cases, to say the
least: see apollographql/invariant-packages#18,
apollographql/invariant-packages#19, apollographql#6604,

However, this vague guidance (which was intended to suggest searching
your installed node_modules/@apollo/client package for the error code)
has not proven adequate in many cases, to say the least: see apollographql/invariant-packages#18,
apollographql/invariant-packages#19, apollographql#6604, apollographql#5730, apollographql#5291, and apollographql#5975,
to cite just a few of the many issues we've seen since apollographql#4521.

Using error codes instead of error strings remains important for
production bundle sizes, but I think we can make it substantially easier
to look up the error string corresponding to each error code, by
generating a single file containing all the invariant error codes for each
@apollo/client release.

Starting with Apollo Client 3.1.0, this manifest file can be found in
@apollo/client/invariantErrorCodes.js (using an npm/yarn-installed copy of
@apollo/client, since this file is generated in the ./dist directory, not
checked into the repository). The file contains an explanatory comment,
the @apollo/client version, and a sequential map from error numbers to the
{ file, node } responsible for the error.
@chrise86
Copy link

@cwshevlin did you manage to resolve your issue? I'm facing the same thing now (Invariant Violation: 8).

@balazsorban44
Copy link
Author

apollographql/apollo-client#6665 This should be of help to newcomers.

@sandorvasas
Copy link

So, maybe apollo should just print the messages themselves into the error, instead of having developers go through jungles of forums to find what it means?

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

5 participants