Skip to content

Conversation

@penalosa
Copy link
Contributor

@penalosa penalosa commented Feb 4, 2025

This PR adds two features (separate changesets):

  • Support for the --outfile argument for wrangler deploy, which outputs the exact Worker bundle that Wrangler will upload to the Cloudflare API. This has more information than just --outdir because it bakes in bindings & module types.
  • wrangler check startup, which profiles the startup time of a Worker and generates a .cpuprofile file that can be opened in Chrome DevTools/directly in VSCode for further investigation. Additionally, this is automatically generated when Wrangler encounters a startup time error from the API.

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Public documentation

@penalosa penalosa requested a review from a team as a code owner February 4, 2025 17:01
@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: fe24f1c

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

@penalosa penalosa force-pushed the penalosa/check-startup branch from 50f8524 to 682fc9b Compare February 4, 2025 17:18
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2025

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/13309873717/npm-package-wrangler-8026

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8026/npm-package-wrangler-8026

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-wrangler-8026 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-workers-bindings-extension-8026 -O ./cloudflare-workers-bindings-extension.0.0.0-veecac04cc.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-veecac04cc.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-create-cloudflare-8026 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-kv-asset-handler-8026

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-miniflare-8026

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-pages-shared-8026

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-unenv-preset-8026

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-vite-plugin-8026

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-vitest-pool-workers-8026

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-workers-editor-shared-8026

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-workers-shared-8026

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13309873717/npm-package-cloudflare-workflows-shared-8026

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20250204.0
workerd 1.20250204.0 1.20250204.0
workerd --version 1.20250204.0 2025-02-04

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

@penalosa penalosa force-pushed the penalosa/check-startup branch 2 times, most recently from 71e85b3 to 07d1f70 Compare February 4, 2025 18:14
@penalosa penalosa force-pushed the penalosa/check-startup branch from d6c31a2 to 650bd73 Compare February 7, 2025 16:22
@penalosa penalosa force-pushed the penalosa/check-startup branch from 650bd73 to 6d62eeb Compare February 7, 2025 18:10
@penalosa penalosa added the e2e Run wrangler + vite-plugin e2e tests on a PR label Feb 10, 2025
Copy link
Contributor

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

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

Pages build already has an outfile, is this supposed to reuse that...? Can pages deploy fail due to startup time, and should this generate a cpuprofile if that's the case?


const mimeTypeModuleType = flipObject(moduleTypeMimeType);

export const checkNamespace = createNamespace({
Copy link
Contributor

Choose a reason for hiding this comment

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

not blocking, especially since its hidden, but it feels odd this has its own command. Do we anticipate other 'check' commands?

...maybe we should make wrangler deploy --dry-run a check command?? (come to think of it, maybe we should resurrect wrangler build for wrangler deploy --dry-run 🤔)
(these are only semi-serious suggestions)

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 agree–we should definitely resurrect wrangler build!

In terms of the command structure here, I went with check startup since it seemed feasible that we might want to have other check * commands in future (check types? check config?), but since this is an alpha command we can always change that later.

@penalosa
Copy link
Contributor Author

Pages build already has an outfile, is this supposed to reuse that...?

It's meant to be doing that, yeah—does that seem buggy to you?

@emily-shen
Copy link
Contributor

Pages build already has an outfile, is this supposed to reuse that...?

It's meant to be doing that, yeah—does that seem buggy to you?

Ah no that’s fine, the lack of changes in the pages deploy path just threw me for a moment but it makes sense now.

Will the cpuprofile be generated automatically if a pages deploy fails?

@penalosa
Copy link
Contributor Author

Will the cpuprofile be generated automatically if a pages deploy fails?

It will now!

@penalosa penalosa requested a review from a team as a code owner February 13, 2025 13:37
Copy link
Contributor

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

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

👏🚀

@penalosa penalosa merged commit 542c6ea into main Feb 13, 2025
29 checks passed
@penalosa penalosa deleted the penalosa/check-startup branch February 13, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Run wrangler + vite-plugin e2e tests on a PR

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants