-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: handle env and stage errors cleanly. Closes #1942 #1943
Conversation
|
6d590d1
to
31e6200
Compare
packages/venia-concept/package.json
Outdated
@@ -29,7 +29,7 @@ | |||
"storybook:build": "yarn run storybook", | |||
"test": "yarn run -s prettier:check && yarn run -s lint && jest", | |||
"validate-queries": "yarn run download-schema && graphql validate-magento-pwa-queries --project venia", | |||
"watch": "webpack-dev-server --progress --color --env.mode development" | |||
"watch": "buildpack load-env . && webpack-dev-server --progress --color --env.mode development" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key here, right? We now validate the environment before running the dev server. We should add this to start:debug and to the watch:all script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it belongs in start:debug, but it definitely belongs in watch:all. Good looking out.
@@ -11,6 +11,11 @@ const path = require('path'); | |||
async function serve() { | |||
const config = loadEnvironment(__dirname); | |||
|
|||
if (config.error) { | |||
// loadEnvironment takes care of logging it | |||
process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test this I had to do:
❯ DEV_SERVER_PORT=bad yarn run stage:venia
Just FYI for other verifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry, I didn't copy the verification steps over from #1942.
throw err; | ||
} | ||
const error = err || msg; | ||
prettyLogger.error(error.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I test this? I commented out this code and nothing happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a fallback error handler for an unrecognized command. If you comment it out and run buildpack
with no arguments, you'll see the difference. It belongs in this ticket because it's about handling errors cleanly, and this fallback error handler will handle all errors in upcoming versions of yargs
.
fix: watch:all and handler comment
282a44a
to
fe2bc57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did make changes! Thanks :)
@zetlen |
package.json
Outdated
@@ -31,6 +31,7 @@ | |||
"prepare": "node scripts/monorepo-introduction.js", | |||
"prettier": "prettier --loglevel warn --write '@(packages|scripts)/**/*.@(css|graphql|js)' '*.js'", | |||
"prettier:check": "prettier --list-different '@(packages|scripts)/**/*.@(css|graphql|js)' '*.js'", | |||
"prevenia": "node ./packages/pwa-buildpack/bin/buildpack load-env ./packages/venia-concept", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is prevenia
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It runs before yarn run venia
. I'm just using the NPM scripts pre
feature here to make the code a little easier to read. But I guess it didn't work on you. Should I just put this in venia
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting. So since venia
is just shorthand for yarn workspace @magento/venia-concept
, this script runs every time yarn venia
is invoked.
This is clever, but it may result in some surprising outcomes. If someone doesn't know about your venia
shorthand, and tries to do a standard thing such as yarn workspace @magento/venia-concept run validate-queries
, they'll miss out on load-env
and probably be confused about why it's not working.
At least if all of that is in venia
, they'll immediately see what the problem was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. The rest of our scripts are littered with shell &&
s, so that's what this will be too.
re-verified after recent commits, looks good. |
Description
loadEnvironment()
Related Issue
Closes #1942.
Acceptance
Verification Stakeholders
@dpatil-magento
Verification Steps
Verify that #1942 is no longer reproducible when the environment is invalid.
Checklist