-
Notifications
You must be signed in to change notification settings - Fork 1k
add remote bindings support to getPlatformProxy
#9688
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
Merged
CarmenPopoviciu
merged 15 commits into
main
from
dario/DEVX-2028/mixed-mode-get-platform-proxy
Jun 20, 2025
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
42c2d23
add remote bindings support to `getPlatformProxy`
dario-piotrowicz 10e7f66
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz d3bcc90
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz d9f0a7f
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz b44fad4
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz 0e1b23c
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz 41ed675
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz 2a248ae
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz b67b22f
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz 3684fa7
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz 90aed0a
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz e78b859
fixup! add remote bindings support to `getPlatformProxy`
dario-piotrowicz 5f1d352
revert targetEnvironment variable renaming
dario-piotrowicz 869a6fd
remove extra env passing
dario-piotrowicz 86f2189
rename rawConfig to just config
dario-piotrowicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "wrangler": patch | ||
| --- | ||
|
|
||
| add remote bindings support to `getPlatformProxy` | ||
92 changes: 92 additions & 0 deletions
92
fixtures/get-platform-proxy-remote-bindings-node-test/index.test.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { execSync } from "child_process"; | ||
| import { randomUUID } from "crypto"; | ||
| import assert from "node:assert"; | ||
| import { mkdirSync, rmSync, writeFileSync } from "node:fs"; | ||
| import test, { after, before, describe } from "node:test"; | ||
| import { getPlatformProxy } from "wrangler"; | ||
|
|
||
| if ( | ||
| !process.env.TEST_CLOUDFLARE_API_TOKEN || | ||
| !process.env.TEST_CLOUDFLARE_ACCOUNT_ID | ||
| ) { | ||
| console.warn("No credentials provided, skipping test..."); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| const env = { | ||
| ...process.env, | ||
| CLOUDFLARE_API_TOKEN: process.env.TEST_CLOUDFLARE_API_TOKEN, | ||
| CLOUDFLARE_ACCOUNT_ID: process.env.TEST_CLOUDFLARE_ACCOUNT_ID, | ||
| }; | ||
|
|
||
| describe("getPlatformProxy remote-bindings", () => { | ||
| const remoteWorkerName = `get-platform-proxy-remote-worker-test-${randomUUID().split("-")[0]}`; | ||
|
|
||
| before(async () => { | ||
| // Note: ideally we pass the auth data to `getPlatformProxy`, that currently is not | ||
dario-piotrowicz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // possible (DEVX-1857) so we need to make sure that the CLOUDFLARE_ACCOUNT_ID | ||
| // and CLOUDFLARE_API_TOKEN env variables are set so that `getPlatformProxy` | ||
| // can establish the remote proxy connection | ||
| process.env.CLOUDFLARE_ACCOUNT_ID = process.env.TEST_CLOUDFLARE_ACCOUNT_ID; | ||
| process.env.CLOUDFLARE_API_TOKEN = process.env.TEST_CLOUDFLARE_API_TOKEN; | ||
|
|
||
| const deployOut = execSync( | ||
| `pnpm dlx wrangler deploy remote-worker.js --name ${remoteWorkerName} --compatibility-date 2025-06-19`, | ||
| { | ||
| stdio: "pipe", | ||
| env, | ||
| } | ||
| ); | ||
|
|
||
| if ( | ||
| !new RegExp(`Deployed\\s+${remoteWorkerName}\\b`).test(`${deployOut}`) | ||
| ) { | ||
| throw new Error(`Failed to deploy ${remoteWorkerName}`); | ||
| } | ||
|
|
||
| rmSync("./.tmp", { recursive: true, force: true }); | ||
|
|
||
| mkdirSync("./.tmp"); | ||
|
|
||
| writeFileSync( | ||
| "./.tmp/wrangler.json", | ||
| JSON.stringify( | ||
| { | ||
| name: "get-platform-proxy-fixture-test", | ||
| compatibility_date: "2025-06-01", | ||
| services: [ | ||
| { | ||
| binding: "MY_WORKER", | ||
| service: remoteWorkerName, | ||
| experimental_remote: true, | ||
| }, | ||
| ], | ||
| }, | ||
| undefined, | ||
| 2 | ||
| ), | ||
| "utf8" | ||
| ); | ||
| }); | ||
|
|
||
| test("getPlatformProxy works with remote bindings", async () => { | ||
| const { env, dispose } = await getPlatformProxy({ | ||
| configPath: "./.tmp/wrangler.json", | ||
| experimental: { remoteBindings: true }, | ||
| }); | ||
|
|
||
| try { | ||
| assert.strictEqual( | ||
| await (await env.MY_WORKER.fetch("http://example.com")).text(), | ||
| "Hello from a remote Worker part of the getPlatformProxy remote bindings fixture!" | ||
| ); | ||
| } finally { | ||
| await dispose(); | ||
| } | ||
| }); | ||
|
|
||
| after(async () => { | ||
| execSync(`pnpm dlx wrangler delete --name ${remoteWorkerName}`, { env }); | ||
| rmSync("./.tmp", { recursive: true, force: true }); | ||
| }); | ||
| }); | ||
19 changes: 19 additions & 0 deletions
19
fixtures/get-platform-proxy-remote-bindings-node-test/package.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "@fixture/get-platform-proxy-remote-bindings-node-test", | ||
| "private": true, | ||
| "description": "", | ||
| "license": "ISC", | ||
| "author": "", | ||
| "type": "module", | ||
| "scripts": { | ||
| "test:ci": "node --test" | ||
| }, | ||
| "devDependencies": { | ||
| "@cloudflare/workers-tsconfig": "workspace:*", | ||
| "@cloudflare/workers-types": "^4.20250617.0", | ||
| "wrangler": "workspace:*" | ||
| }, | ||
| "volta": { | ||
| "extends": "../../package.json" | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
fixtures/get-platform-proxy-remote-bindings-node-test/remote-worker.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default { | ||
| fetch() { | ||
| return new Response( | ||
| "Hello from a remote Worker part of the getPlatformProxy remote bindings fixture!" | ||
| ); | ||
| }, | ||
| }; |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.