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

Instructions are way too vague #18

Closed
dobesv opened this issue Apr 20, 2020 · 3 comments
Closed

Instructions are way too vague #18

dobesv opened this issue Apr 20, 2020 · 3 comments

Comments

@dobesv
Copy link

dobesv commented Apr 20, 2020

Since the full development version of the error is colocated with the production one in code that has been transformed by rollup-plugin-invariant, it should be relatively easy to determine the nature of the error by looking for the given error code in the unminified bundle.

Although it says "it should be relatively easy" I honestly have no idea what I'm supposed to be looking for. Maybe an example would help?

@penx
Copy link

penx commented Apr 27, 2020

Same here. I've not used this module personally, I guess a team member has. I see this error in the CI logs and it directs me here. Not sure where to begin after reading that. Should the readme be linking to a certain file within the project?

@dobesv
Copy link
Author

dobesv commented Apr 27, 2020

It looks like the idea is to grep for _tsInvarient.invariant or InvariantError, something like this:

# If you're using ES modules (probably the case if you're using webpack, but I'm not 100% sure)
$ grep -ir "invariant.*17)" node_modules/apollo-client/bundle.esm.js
            process.env.NODE_ENV === "production" ? invariant(foundObserveableQuery, 17) : invariant(foundObserveableQuery, "ObservableQuery with this id doesn't exist: " + queryIdOrObservable);
# If you're using commonjs bundle (e.g. in node.js)
$ grep -ir "invariant.*17)" node_modules/apollo-client/bundle.cjs.js
      process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(foundObserveableQuery, 17) : (0, _tsInvariant.invariant)(foundObserveableQuery, "ObservableQuery with this id doesn't exist: " + queryIdOrObservable);

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.
@balazsorban44
Copy link

apollographql/apollo-client#6665 This should help from now on. If @dobesv agrees, this could be closed.

@dobesv dobesv closed this as completed Aug 18, 2020
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