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

Blog post for error codes #7229

Merged
merged 1 commit into from
Jul 12, 2016
Merged

Blog post for error codes #7229

merged 1 commit into from
Jul 12, 2016

Conversation

zpao
Copy link
Member

@zpao zpao commented Jul 8, 2016

Mostly just took what @keyanzhang sent me and tweaked a couple sentences/links.

screen shot 2016-07-08 at 16 20 19-fullpage


Building a better developer experience has been one of the things that React deeply cares about, and a crucial part of it is to detect anti-patterns/potential errors early and provide helpful error messages when things (may) go wrong. However, most of these only exist in development mode; in production, we avoid having extra expensive assertions and sending down full error messages in order to reduce the number of bytes sent over the wire. Prior to this release, we stripped out error messages at build-time and this is why you see the "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." message in production.

In order to make debugging in production easier, we're introducing an Error Code System in 15.2.0. We developed a [gulp script](https://github.com/facebook/react/blob/master/scripts/error-codes/gulp-extract-errors.js) that collects all of our `invariant` error messages and folds them to a [JSON file](https://github.com/facebook/react/blob/master/scripts/error-codes/codes.json), and at build-time Babel uses the JSON to [rewrite](https://github.com/facebook/react/blob/master/scripts/error-codes/dev-expression-with-codes.js) our `invariant` calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled. While we hope you don't see errors often, you can see how it works [here](/react/docs/error-decoder.html?invariant=109&args[]=Foo). This feature shouldn't require any changes on your side — use the `min.js` files in production or bundle your application code with `process.env.NODE_ENV === 'production'` and you should be good to go!
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15.2.0

Going to turn that into a link to https://github.com/facebook/react/releases/tag/v15.2.0.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's break out a blockquote here too:


Now you'll see an error like this:

Minified React error #109; visit https://facebook.github.io/react/docs/error-decoder.html?invariant=109&args[]=Foo for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention how codes keep the bundle size small? Not sure if that's implicit.

@zpao zpao force-pushed the blog-post-errorcodes branch from ead9f7f to 3bcc293 Compare July 11, 2016 22:56
@zpao
Copy link
Member Author

zpao commented Jul 11, 2016

Updated screenshot: screen shot 2016-07-11 at 16 24 01-fullpage

@keyz
Copy link
Contributor

keyz commented Jul 11, 2016

Thanks for helping me to polish this @zpao @spicyj!

@sophiebits
Copy link
Collaborator

Can you add a paragraph break before "Prior to this release" and before "While we hope"? Sorta wall-of-text–y right now.

@zpao zpao force-pushed the blog-post-errorcodes branch from 3bcc293 to f5a11dc Compare July 12, 2016 00:39
@zpao zpao merged commit 92492e0 into facebook:master Jul 12, 2016
zpao added a commit that referenced this pull request Jul 12, 2016
Blog post for error codes
(cherry picked from commit 92492e0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants