Skip to content

Support dynamic worker loading#10012

Merged
penalosa merged 1 commit intomainfrom
penalosa/support-dynamic-worker-loading
Aug 19, 2025
Merged

Support dynamic worker loading#10012
penalosa merged 1 commit intomainfrom
penalosa/support-dynamic-worker-loading

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Jul 18, 2025

Support cloudflare/workerd#4383


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this is an experimental pre-release feature
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not available in v3

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jul 18, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10012

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10012

miniflare

npm i https://pkg.pr.new/miniflare@10012

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10012

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10012

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10012

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10012

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10012

wrangler

npm i https://pkg.pr.new/wrangler@10012

commit: 34d24b0

@penalosa penalosa force-pushed the penalosa/support-dynamic-worker-loading branch from 18d1593 to c68e12a Compare August 8, 2025 13:03
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Aug 8, 2025

🦋 Changeset detected

Latest commit: 34d24b0

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

This PR includes changesets to release 5 packages
Name Type
miniflare Minor
wrangler Minor
@cloudflare/pages-shared Patch
@cloudflare/vite-plugin Major
@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 marked this pull request as ready for review August 8, 2025 13:17
@penalosa penalosa requested a review from a team as a code owner August 8, 2025 13:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 8, 2025

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main penalosa/support-dynamic-worker-loading might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-10012
  • add the skip-v3-pr label to the current PR to stop this workflow from failing

@danlapid
Copy link
Copy Markdown
Contributor

danlapid commented Aug 8, 2025

Maybe @kentonv will have some comments

Comment thread .changeset/tall-emus-sing.md Outdated
Comment on lines 2 to 3
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Surely minors?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does id mean in this binding.
I guess my question is, "What does it mean to have multiple Worker Loaders?"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Miniflare should randomly-generate this ID instead. It turns out the edge runtime doesn't support multiple bindings to the same worker loader namespace so there's not much reason to expose this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh wait, no need to randomly generate. It can just be left null (not empty string, but null/omitted), in which case workerd will do the right thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will it be needed for production deployments? In other words can we just remove it from wrangler.jsonc altogether? Or just ignore it in local dev?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Production does not support this option at all, that's why I recommend removing it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not accessible from getPlatformProxy()?

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Aug 8, 2025
@petebacondarwin
Copy link
Copy Markdown
Contributor

Approved as this is good as it stands but I do think it would be nice to support getPlatformProxy() if it doesn't already.

@kentonv
Copy link
Copy Markdown
Member

kentonv commented Aug 11, 2025

I'd love to see this merged and released soon as I need it for a project. :)

@threepointone
Copy link
Copy Markdown
Contributor

Let's talk about this before landing it? Just want to make sure we agree on the api and how we're going to roll it out. @kentonv you can use this locally immediately with the prerelease builds npm i https://pkg.pr.new/wrangler@10012

Copy link
Copy Markdown
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

soft blocking just so we can chat about this

@github-project-automation github-project-automation Bot moved this from Approved to In Review in workers-sdk Aug 11, 2025
@penalosa
Copy link
Copy Markdown
Contributor Author

@threepointone this isn't a stable release—it's going out as an unsafe binding. We can (and probably will) change the API/binding config before graduating to a stable binding

@github-project-automation github-project-automation Bot moved this from In Review to Approved in workers-sdk Aug 11, 2025
@penalosa penalosa requested a review from a team August 11, 2025 15:39
@penalosa penalosa force-pushed the penalosa/support-dynamic-worker-loading branch 6 times, most recently from 01df07d to b3b5040 Compare August 14, 2025 19:50
@kentonv
Copy link
Copy Markdown
Member

kentonv commented Aug 15, 2025

Not sure if this is a problem in this PR or pre-existing, but I noticed that when I run wrangler dev, this binding is displayed wrong:

Your Worker has access to the following bindings:
Binding                                                      Resource             Mode
env.worker-loader (LOADER)                                   Unsafe Metadata      not supported

The binding name and type are swapped in the display -- it should say:

env.LOADER (worker-loader)                                   Unsafe Metadata      not supported

(The binding seems to work, though. This is just a display problem.)

@penalosa penalosa force-pushed the penalosa/support-dynamic-worker-loading branch from 36135ca to d06fde9 Compare August 18, 2025 10:03
@penalosa penalosa force-pushed the penalosa/support-dynamic-worker-loading branch from 902f092 to 34d24b0 Compare August 19, 2025 13:13
@penalosa penalosa merged commit 4728c68 into main Aug 19, 2025
38 of 44 checks passed
@penalosa penalosa deleted the penalosa/support-dynamic-worker-loading branch August 19, 2025 16:09
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Aug 19, 2025
erifystudio

This comment was marked as spam.

erifystudio

This comment was marked as spam.

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.

7 participants