-
Notifications
You must be signed in to change notification settings - Fork 774
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(wrangler): fix build-env
to exit with code rather than throw fatal error
#5572
Conversation
🦋 Changeset detectedLatest commit: 0c5d39e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
031565a
to
a3371e2
Compare
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-wrangler-5572 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5572/npm-package-wrangler-5572 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-wrangler-5572 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-create-cloudflare-5572 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-cloudflare-kv-asset-handler-5572 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-miniflare-5572 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-cloudflare-pages-shared-5572 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8646310607/npm-package-cloudflare-vitest-pool-workers-5572 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
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.
Please can we remove the calls to process.exit()
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 wonder if, separately to this we should mention in the logs (especially for when there is a warning) that wrangler.toml usage is beta?
true | ||
); | ||
} catch (err) { | ||
logger.log("Invalid Pages configuration file found. Exiting."); |
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 should be a warning using logger.warn which will write to stderr instead of stdout
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 shouldn't be a warning, which will show up as a scary messaging, when this is an expected case. This should be a debug log
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 think this underlines the need for the text of these messages to be less scary themselves.
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 went ahead and done the following wrt messaging:
- introduced a one liner
BETA
log (Checking for configuration in a wrangler.toml (BETA)
) as per our conversation. Keeping in wrangler so we can remove more easily when time comes - used
logger.debug
instead oflogger.log
in the wrangler command. This gets rid of the double messaging we were seeing in the CI logs. Makes running thebuild-env
command in the terminal a bit unfriendly if not run withWRANGLER_LOG="debug"
. However, since this is not a public API, I'm OK with the tradeoff - Updated the CI logs as per our conversation
I'll update description with how the final messaging looks like in CI, once all things are built
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 assume the (BETA) message is in pages-infra?
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 kept the (BETA) message in wrangler, so it stays within our scope, and can remove more easily when time comes
…tal error Currently `pages functions build-env` throws a fatal error if a config file does not exit, or if it is invalid. This causes issues for the CI system. We should instead exit with a specific code, if any of those situations arises.
true | ||
); | ||
} catch (err) { | ||
logger.log("Invalid Pages configuration file found. Exiting."); |
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 assume the (BETA) message is in pages-infra?
bc804d9
to
0c5d39e
Compare
); | ||
} catch (err) { | ||
logger.debug("wrangler.toml file is invalid. Exiting."); | ||
process.exitCode = EXIT_CODE_INVALID_PAGES_CONFIG; |
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.
Why did we do this format instead of throwing a fatal error with a custom error code like we do for other errors communicated to Pages CI? e.g. https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/config/index.ts#L93
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.
We don't exit with FatalError
s any more (that one you linked is caught by this catch handler)
What this PR solves / how to test
Currently
pages functions build-env
throws a fatal error if a config file does not exit, or if it isinvalid. This causes issues for the CI system. We
should instead exit with a specific code, if any of those situations arises.
You can test by running
npx wrangler pages function build-env [directory] --outfile=<file-name.json>
Author has addressed the following
How this PR was tested
WRANGLER_LOG="debug"
WRANGLER_LOG="debug"
WRANGLER_LOG="debug"
WRANGLER_LOG="debug"
PREVIEW OF CI ERR MESSAGING