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(wrangler): fix build-env to exit with code rather than throw fatal error #5572

Merged
merged 3 commits into from
Apr 11, 2024

Conversation

CarmenPopoviciu
Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu commented Apr 9, 2024

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 is
invalid. 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

  • with valid Pages config file
Screenshot 2024-04-11 at 12 06 05
  • with non-Pages config file + WRANGLER_LOG="debug"
Screenshot 2024-04-11 at 12 07 08
  • with invalid Pages config file + WRANGLER_LOG="debug"
Screenshot 2024-04-11 at 12 07 08
  • with invalid non-Pages config file + WRANGLER_LOG="debug"
Screenshot 2024-04-11 at 12 07 08
  • with no config file + WRANGLER_LOG="debug"
Screenshot 2024-04-11 at 12 06 42

PREVIEW OF CI ERR MESSAGING

Screenshot 2024-04-11 at 13 48 14 Screenshot 2024-04-11 at 13 53 30

@CarmenPopoviciu CarmenPopoviciu requested review from a team as code owners April 9, 2024 20:20
Copy link

changeset-bot bot commented Apr 9, 2024

🦋 Changeset detected

Latest commit: 0c5d39e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Minor
@cloudflare/vitest-pool-workers Patch

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

Copy link
Contributor

github-actions bot commented Apr 9, 2024

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 with this latest build directly:

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.


wrangler@3.49.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240405.0
workerd 1.20240405.0 1.20240405.0
workerd --version 1.20240405.0 2024-04-05

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link
Contributor

@petebacondarwin petebacondarwin left a 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()

Copy link
Contributor

@petebacondarwin petebacondarwin left a 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.");
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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:

  1. 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
  2. used logger.debug instead of logger.log in the wrangler command. This gets rid of the double messaging we were seeing in the CI logs. Makes running the build-env command in the terminal a bit unfriendly if not run with WRANGLER_LOG="debug". However, since this is not a public API, I'm OK with the tradeoff
  3. 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

Copy link
Contributor

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?

Copy link
Contributor Author

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

Carmen Popoviciu added 3 commits April 11, 2024 08:53
…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.");
Copy link
Contributor

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?

@CarmenPopoviciu CarmenPopoviciu merged commit 65aa21c into main Apr 11, 2024
15 checks passed
@CarmenPopoviciu CarmenPopoviciu deleted the carmen/build-env branch April 11, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants