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

Fix error codes #7999

Merged
merged 5 commits into from
Nov 8, 2016
Merged

Fix error codes #7999

merged 5 commits into from
Nov 8, 2016

Conversation

keyz
Copy link
Contributor

@keyz keyz commented Oct 18, 2016

I noticed that the error code in the 15-dev branch is not in sync with a freshly generated one (#7963) or in master. Specifically some invariants in src/isomorphic/hooks are missing. This is probably caused by this change while we were splitting the packages.

In this PR I copied the codes.json file from the 15-dev branch and fixed the gulp script. and regenerated error codes. For now, we only regenerate error codes when we cut a release and the master one doesn't get updated; It might be better if we sync the codes.json file back to master after each release, otherwise it'd be hard to modify an existing error message (like #7963).

Edited: please see a better process at #7999 (comment).

Reviewers:
@sebmarkbage @gaearon and cc @zpao

Test Plan:

  • run npm run build with the latest codes.json and there should be no warnings

gulp.src(paths.reactDOM.src),
gulp.src(paths.reactNative.src),
gulp.src(paths.reactTestRenderer.src)
).pipe(extractErrors(errorCodeOpts));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you explain what's going on here? Why does this matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error code generator was written in a way that it reads the file first, traverses the AST, and appends to the target file. I guess when we invoke it multiple times it causes a race condition and overwrites the same file.

To be honest there should a better way if I'm more knowledgeable in Gulp :). This PR simply changes it back to the way that the generator was used.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, pretty sure that's racing. FWIW, you can probably just gulp.src([array of paths]).pipe(...) (can't test though right now so could be wrong).

@keyz
Copy link
Contributor Author

keyz commented Oct 18, 2016

@zpao thanks, I changed it to use gulp.src([].concat(...)) instead. The order of errors should be more stable this way.

@keyz
Copy link
Contributor Author

keyz commented Oct 20, 2016

Friendly ping: this needs to be fixed for the 15.4.0 release.

@sebmarkbage
Copy link
Collaborator

Which branches does this need to be merged into?

@keyz
Copy link
Contributor Author

keyz commented Oct 20, 2016

Other than the script update, I recommend merging the codes into master to unblock things like #7963. Specifically #7963 modifies an existing invariant message, and there's a test for the behavior in production so the PR author needs to regenerate the error codes.

@zpao updates the error codes when he cuts a release so only the codes in 15-dev and 15-stable get updated. I think we should sync the codes.json file back to master after each release (or just run it in master first and sync to a version branch). What do you think?

@gaearon
Copy link
Collaborator

gaearon commented Oct 21, 2016

@zpao updates the error codes when he cuts a release

I didn’t know this, and didn’t update them when cutting RCs. Do I need to?

Since @zpao is transitioning out of the team it would be great if you could provide instructions for what to do before the release, and what should not be done. Apologies if you provided them before.

@gaearon
Copy link
Collaborator

gaearon commented Oct 21, 2016

I also noticed that the error transform spews warnings every time I run npm run build on master. I wasn't sure if I'm supposed to ignore them or run extract-errors right away. By now I'm so used to this warning that I completely ignore it. What should I have done instead?

@iamdustan
Copy link
Contributor

Is #7330 @zpao encoding his brain into a tool to manage releases in the future?

@keyz keyz force-pushed the fix-error-codes branch 2 times, most recently from 6237ec2 to d7347d2 Compare October 24, 2016 06:51
@keyz
Copy link
Contributor Author

keyz commented Oct 24, 2016

@gaearon Sorry about the delay. We've only talked about this in chats and I don't think I've formally documented it down. I just added a README for the error code system.

I also added a note for cutting a new release as follows (copied from the new README):

  1. For each release, we run gulp react:extract-errors to update the error codes before calling npm run build. The build process uses codes.json for a production (minified) build; there should be no warning like Error message "foo" cannot be found for a successful release.
  2. The updated codes.json file should be synced back to the master branch. The error decoder page in our documentation site uses codes.json from master; if the json file has been updated, the docs site should also be rebuilt (rake copy_error_codes is included in the default rake release task).
  3. It's not recommended to run gulp react:extract-errors directly in master since it may contain commits that are not cherry-picked to a release branch. These error messages might be changed/removed before cutting a new release, and we don't want to add intermediate/temporary error messages to codes.json. However, if a PR changes an existing error message and there's a specific production test (which is rare), it's ok to update codes.json for that. Please use gulp react:extract-errors and don't edit the file manually.

I thought about this again and I think this is a better process for keeping everything in sync. Therefore I reverted the commit for updating codes.json in master. Are the instructions clear? Please let me know if there are still questions.

@zpao
Copy link
Member

zpao commented Oct 25, 2016

I think running in master and cherrypicking back might not be safe unless
we do it on every invariant change (could get into situation where
invariant added in A and changed in B but only A is cherry-picked for
release in 15). So I've just been doing it on the releases (but should also
do it for RCs, sorry for missing that). We should cherry pick that back to
master though.

On Friday, October 21, 2016, Dustan Kasten notifications@github.com wrote:

Is #7330 #7330 @zpao
https://github.com/zpao encoding his brain into a tool to manage
releases in the future?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7999 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAg_dmm10Q6XjE4zGfYRdkRKSDnzk90ks5q2LxpgaJpZM4KZT3w
.

@keyz
Copy link
Contributor Author

keyz commented Oct 25, 2016

@zpao Thanks! Yeah I thought about it again and I agree with you (there's an updated workflow at #7999 (comment)).

@keyz
Copy link
Contributor Author

keyz commented Oct 25, 2016

@gaearon Just saw your updates in #8033. Just making sure, did you intend to let the script collect error messages in reactNoopRenderer (https://github.com/facebook/react/pull/8033/files#diff-b9e12334e9eafd8341a6107dd98510c9R274)? Since reactNoopRenderer is not publicly released yet and no one uses its prod build, I recommend not to add it for now to avoid adding intermediate/temporary error messages to codes.json.

gulp.src(paths.reactDOM.src).pipe(extractErrors(errorCodeOpts)),
gulp.src(paths.reactNative.src).pipe(extractErrors(errorCodeOpts)),
gulp.src(paths.reactTestRenderer.src).pipe(extractErrors(errorCodeOpts)),
gulp.src(paths.reactNoopRenderer.src).pipe(extractErrors(errorCodeOpts))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gaearon I rebased and removed reactNoopRenderer from the list of extract-errors targets. Please let me know if it makes sense!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea, totally. I was just copy pasting.

@gaearon
Copy link
Collaborator

gaearon commented Oct 27, 2016

Keyan, what is my next step? Merge this in master and cherry pick to 15-stable and 15-dev?

@keyz
Copy link
Contributor Author

keyz commented Oct 27, 2016

@gaearon Yeah, for this PR, let's:

  1. Merge this PR in master
  2. Cherry pick to 15-stable and 15-dev

When you cut a release, let's do:

  1. Run gulp react:extract-errors in 15-dev
  2. If codes.json gets updated, please cherry pick it back to master and 15-stable
  3. npm run build and other release tasks

@gaearon gaearon merged commit 46609cb into facebook:master Nov 8, 2016
gaearon pushed a commit that referenced this pull request Nov 8, 2016
* took codes.json from the 15-dev branch

* fixed react:extract-errors task in gulpfile

* generated error codes

* Revert "generated error codes"

This reverts commit b8f3aee.

* Added a README for the error code system
gaearon pushed a commit that referenced this pull request Nov 8, 2016
* took codes.json from the 15-dev branch

* fixed react:extract-errors task in gulpfile

* generated error codes

* Revert "generated error codes"

This reverts commit b8f3aee.

* Added a README for the error code system
@gaearon gaearon mentioned this pull request Nov 8, 2016
acusti pushed a commit to brandcast/react that referenced this pull request Mar 15, 2017
* took codes.json from the 15-dev branch

* fixed react:extract-errors task in gulpfile

* generated error codes

* Revert "generated error codes"

This reverts commit b8f3aee.

* Added a README for the error code system
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.

6 participants