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

feat(wrangler): Add remote mode support for Workers + Assets #7380

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

CarmenPopoviciu
Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu commented Nov 28, 2024

Fixes DEVX-1522

This PR adds remote mode support in wrangler dev for Workers + Assets.

The current implementation will always upload assets to the edge, before deploying the User Worker to Edge Preview (which is what wrangler dev --remote already does). This means that for Workers + Assets, the User Worker, Router Worker, Asset Workers, the assets and any other resources all run at the edge (see diagram below).

Screenshot 2024-11-29 at 11 19 19

Screenshots

  • Worker + Assets only
Screenshot 2024-12-17 at 15 16 31 Screenshot 2024-12-17 at 15 17 06
  • Worker + Assets
Screenshot 2024-12-17 at 15 23 27 Screenshot 2024-12-17 at 15 19 52

@CarmenPopoviciu CarmenPopoviciu requested a review from a team as a code owner November 28, 2024 13:01
Copy link

changeset-bot bot commented Nov 28, 2024

🦋 Changeset detected

Latest commit: 0f449e9

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 Nov 28, 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/12374611637/npm-package-wrangler-7380

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-wrangler-7380 dev path/to/script.js
Additional artifacts:
wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-workers-bindings-extension-7380 -O ./cloudflare-workers-bindings-extension.0.0.0-vcafe9975c.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-vcafe9975c.vsix
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-create-cloudflare-7380 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-kv-asset-handler-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-miniflare-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-pages-shared-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-unenv-preset-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-vitest-pool-workers-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-workers-editor-shared-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-workers-shared-7380
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12374611637/npm-package-cloudflare-workflows-shared-7380

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.20241205.0
workerd 1.20241205.0 1.20241205.0
workerd --version 1.20241205.0 2024-12-05

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

@CarmenPopoviciu CarmenPopoviciu force-pushed the carmen/assets-remote-mode branch 3 times, most recently from 065afe9 to aba3f32 Compare November 28, 2024 13:17
@CarmenPopoviciu CarmenPopoviciu changed the title feat(wrangler): Add remote mode support for Workers + Assets [DO NOT MERGE] feat(wrangler): Add remote mode support for Workers + Assets Nov 28, 2024
try {
const { workerAccount, workerContext } = await getWorkerAccountAndContext(
Copy link
Contributor Author

@CarmenPopoviciu CarmenPopoviciu Nov 28, 2024

Choose a reason for hiding this comment

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

moving this code higher in the call chain so we can extract the Worker scriptId and pass it into createRemoteWorkerInit. createRemoteWorkerInit needs the Worker name to be defined so that it can make the assets upload API call, which would otherwise have unintended side effects

The logic of this code block has not changed!

@CarmenPopoviciu CarmenPopoviciu force-pushed the carmen/assets-remote-mode branch from aba3f32 to eddd402 Compare November 28, 2024 14:28
@CarmenPopoviciu CarmenPopoviciu added the e2e Run e2e tests on a PR label Nov 28, 2024
@CarmenPopoviciu CarmenPopoviciu force-pushed the carmen/assets-remote-mode branch from eddd402 to 619b25e Compare November 28, 2024 15:39
@petebacondarwin petebacondarwin marked this pull request as draft December 2, 2024 14:21
@CarmenPopoviciu CarmenPopoviciu force-pushed the carmen/assets-remote-mode branch from 619b25e to 5b20edd Compare December 3, 2024 15:06
@CarmenPopoviciu CarmenPopoviciu changed the title [DO NOT MERGE] feat(wrangler): Add remote mode support for Workers + Assets feat(wrangler): Add remote mode support for Workers + Assets Dec 3, 2024
@CarmenPopoviciu CarmenPopoviciu added the blocked Blocked on other work label Dec 5, 2024
@CarmenPopoviciu CarmenPopoviciu force-pushed the carmen/assets-remote-mode branch 2 times, most recently from b2c0f6d to ac26cc7 Compare December 16, 2024 17:30
@CarmenPopoviciu CarmenPopoviciu removed the blocked Blocked on other work label Dec 16, 2024
@CarmenPopoviciu CarmenPopoviciu marked this pull request as ready for review December 16, 2024 17:31
@penalosa
Copy link
Contributor

Just to clarify, this is just running the user worker in remote preview, right? The asset & router worker are both still just the production ones, I thought?

@CarmenPopoviciu
Copy link
Contributor Author

Just to clarify, this is just running the user worker in remote preview, right? The asset & router worker are both still just the production ones, I thought?

yes, that is correct

@CarmenPopoviciu CarmenPopoviciu force-pushed the carmen/assets-remote-mode branch from ac26cc7 to 0f449e9 Compare December 17, 2024 14:02
@CarmenPopoviciu CarmenPopoviciu merged commit 72935f9 into main Dec 17, 2024
32 checks passed
@CarmenPopoviciu CarmenPopoviciu deleted the carmen/assets-remote-mode branch December 17, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants