Skip to content

[wrangler] Extract remote bindings into a package#14720

Merged
penalosa merged 34 commits into
mainfrom
penalosa/manual-remote-bindings
Jul 21, 2026
Merged

[wrangler] Extract remote bindings into a package#14720
penalosa merged 34 commits into
mainfrom
penalosa/manual-remote-bindings

Conversation

@penalosa

Copy link
Copy Markdown
Contributor

Extract the remote bindings implementation from Wrangler into the private @cloudflare/remote-bindings package while preserving Wrangler's public API through logger-injecting wrappers.

This also narrows the copied development runtime to the functionality remote bindings use, makes the package directly importable as ESM, registers a workers.dev subdomain when required for preview sessions, and retains existing proxy sessions when bindings are updated.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this is an internal implementation extraction with no new user-facing API.

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 79808aa

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@ask-bonk

ask-bonk Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Extracts the remote bindings implementation into a private @cloudflare/remote-bindings package and keeps Wrangler's public API via logger-injecting wrappers.

One actionable issue:

1. Unused import will fail lint — packages/wrangler/src/user/access.ts:9

This PR removes the isNonInteractiveOrCI argument from the packageGetAccessHeaders(...) call (workers-auth's getAccessHeaders now imports it directly from @cloudflare/workers-utils), which leaves this import dead:

import { isNonInteractiveOrCI } from "@cloudflare/workers-utils";

isNonInteractiveOrCI is no longer referenced anywhere in the file except the leading comment. The repo's unused-imports/no-unused-vars rule raises errors, so pnpm check / CI will fail. Suggested fix — remove the import:

import { logger } from "../logger";

(applied to lines 9-10, dropping the unused import and keeping the logger import). While you're there, the leading comment (lines 2-3) still says the wrapper "injects wrangler's logger singleton and isNonInteractiveOrCI predicate" — that's now stale and should drop the isNonInteractiveOrCI mention.

Nit (non-blocking): getCloudflareAccessHeaders in packages/workers-auth/src/access.ts:182-184 still declares isNonInteractiveOrCI: () => boolean in its options and passes it through to getAccessHeaders, which no longer reads it. Harmless at runtime, but the migration is left half-done — worth tidying for consistency.

@ask-bonk

ask-bonk Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Posted the review as a top-level PR comment on #14720 (the inline suggestion returned a 422 because the unused-import line falls outside the diff hunk, so I fell back to a PR comment per the instructions).

Summary of findings:

  • Actionable: packages/wrangler/src/user/access.ts:9isNonInteractiveOrCI import is now dead after this PR removed it from the packageGetAccessHeaders(...) call. The repo's unused-imports/no-unused-vars rule errors on this, so pnpm check/CI will fail. Provided a suggestion to drop the import and flagged the stale leading comment.
  • Nit: getCloudflareAccessHeaders in packages/workers-auth/src/access.ts still declares/threads isNonInteractiveOrCI even though getAccessHeaders no longer reads it — harmless but an incomplete migration.

Everything else (the logger singleton init timing, retryOnAPIFailure signature change and its call sites, changeset scope, private-package handling) checked out.

github run

@penalosa
penalosa force-pushed the penalosa/manual-remote-bindings branch from 55ca99a to 235afa1 Compare July 16, 2026 14:43
@penalosa
penalosa marked this pull request as ready for review July 16, 2026 15:24
@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team July 16, 2026 15:24
@workers-devprod

workers-devprod commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14720

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@14720

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14720

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14720

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14720

wrangler

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

commit: 2b3ea8b

@emily-shen emily-shen added the ci:run-remote-tests Run remote/E2E tests that require Cloudflare API credentials label Jul 16, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@jamesopstad
jamesopstad self-requested a review July 20, 2026 10:15
Comment thread packages/remote-bindings/scripts/embed-workers.ts
Comment thread packages/remote-bindings/src/startDevWorker/ProxyController.ts
Comment thread packages/remote-bindings/src/startDevWorker/ProxyController.ts Outdated
Comment thread packages/remote-bindings/src/startDevWorker/ProxyController.ts
Comment thread packages/remote-bindings/src/startDevWorker/RemoteRuntimeController.ts Outdated
Comment thread packages/remote-bindings/src/utils/remote.ts
Comment thread packages/remote-bindings/src/startDevWorker/ProxyController.ts Outdated
Comment thread packages/remote-bindings/src/utils/miniflare.ts Outdated
Comment thread packages/remote-bindings/tsdown.config.ts
@petebacondarwin

Copy link
Copy Markdown
Contributor

This also narrows the copied development runtime to the functionality remote bindings use, makes the package directly importable as ESM, registers a workers.dev subdomain when required for preview sessions, and retains existing proxy sessions when bindings are updated.

What is the goal here? It feels a bit weird to be making these copies (even if they are narrower). This is non-trivial code and any bug in one is likely to be in the other, making an additional maintenance burden. Was there no way to just share the code?

@penalosa

Copy link
Copy Markdown
Contributor Author

What is the goal here? It feels a bit weird to be making these copies (even if they are narrower). This is non-trivial code and any bug in one is likely to be in the other, making an additional maintenance burden. Was there no way to just share the code?

I initially tried that, but pulling the entirety of DevEnv outside of Wrangler proved quite complex, and ended up with similarly hard to review diffs. The goal here is to pull out out remote bindings as a distinct thing from DevEnv, so that we can use remote bindings in Vite and Vitest without depending on Wrangler.

One aspect here is that I don't know that these codebases will necessarily evolve in the same direction. We may end up with remote bindings being powered by some more dedicated system in the future, and we may end up with the remote aspect of DevEnv being deprecated at some point.

@workers-devprod workers-devprod left a comment

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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jul 21, 2026
penalosa and others added 21 commits July 21, 2026 14:30
…oller.ts

Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
- Drop the empty `WranglerLog` wrapper — `ProxyControllerLogger` now extends
  Miniflare's `Log` directly
- De-wrangler-ify the extracted package — `ProxyController` log prefix and the
  tail WebSocket `User-Agent` now say `remote-bindings` rather than `wrangler`
- Move runtime dependencies out of `devDependencies` into `dependencies`,
  matching the convention in other packages
@penalosa
penalosa force-pushed the penalosa/manual-remote-bindings branch from 138abc1 to 79808aa Compare July 21, 2026 13:31
devin-ai-integration[bot]

This comment was marked as resolved.

…artup

`startRemoteProxySession` only unwrapped `RemoteSessionAuthenticationError`
at the error event's direct `cause`, so a `UserError` surfaced asynchronously
(e.g. the Miniflare user-error case) fell through to being wrapped in a generic
`Error`. That made Wrangler treat it as an unexpected internal error (bug
prompt + Sentry report) rather than a clean user-facing error.

Surface a directly-emitted `UserError` verbatim, and walk the error event's
cause chain for a `RemoteSessionAuthenticationError` (mirroring the original
`findRemoteSessionAuthError`). Generic API errors — which also extend
`UserError` via `APIError` — still fall through to the "Failed to start the
remote proxy session" wrapper. Adds regression tests covering each case.
@penalosa
penalosa force-pushed the penalosa/manual-remote-bindings branch from 79808aa to 2b3ea8b Compare July 21, 2026 14:21
@penalosa
penalosa merged commit 0df3d43 into main Jul 21, 2026
67 of 68 checks passed
@penalosa
penalosa deleted the penalosa/manual-remote-bindings branch July 21, 2026 14:46
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-remote-tests Run remote/E2E tests that require Cloudflare API credentials

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants