[wrangler][miniflare] Serve local R2 bucket objects publicly over a dedicated port#14119
Open
tahmid-23 wants to merge 2 commits into
Open
[wrangler][miniflare] Serve local R2 bucket objects publicly over a dedicated port#14119tahmid-23 wants to merge 2 commits into
tahmid-23 wants to merge 2 commits into
Conversation
Introduce an `UnsafePluginSocketRequest` mechanism so plugins can request a dedicated HTTP socket fronting one of their services, bypassing Miniflare's entry worker. Plugins return these via `unsafeSockets` on `ServicesExtensions`, and Miniflare opens the requested socket and tracks it by user binding name. A new `getPublicSocketURL(bindingName)` method on the `Miniflare` class returns the URL of the socket serving a given binding, which is useful when the socket was requested on port `0` and the assigned port isn't known ahead of time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 3bd48b7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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 |
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
0de4635 to
5de38c1
Compare
…edicated port Add an `experimental_local_port` option to R2 bucket bindings. When set, the bucket's objects are served over plain HTTP on a dedicated port during local development, simulating a public R2 bucket. This wires the config field through wrangler dev into Miniflare's R2 plugin, which uses the per-binding socket mechanism to front a new `public.worker` over the requested port. A warning is logged with the public URL so users know the bucket is exposed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5de38c1 to
3bd48b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements the idea discussed in #13325.
R2 exposes a public endpoint for accessing buckets remotely, but no such analogue exists in local development.
This adds a configuration parameter,
experimental_local_port, that sets up a socket for a given R2 binding. This is sent to a custom worker, which translates aGET/HEADrequest into an R2 access. The worker provides full support for range and condition headers.As a brief aside, I'd like to implement S3-compatible pre-signed uploads in the newly created worker in a follow-up PR.
A picture of a cute animal (not mandatory, but encouraged)