Skip to content

Add auth information to maybeStartOrUpdateRemoteProxySession and also fix the example's code formatting #24206

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

Open
wants to merge 2 commits into
base: production
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 30 additions & 34 deletions src/content/docs/workers/development-testing/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ This wrapper simplifies proxy session management. It takes:

- The path to your Wrangler config, or an object with remote bindings.
- The current proxy session details (this parameter can be set to `null` or not being provided if none).
- Potentially the auth data to use for the remote proxy session.

It returns an object with the proxy session details if started or updated, or `null` if no proxy session is needed.

Expand All @@ -395,42 +396,37 @@ import { experimental_maybeStartOrUpdateRemoteProxySession } from "wrangler";

let mf: Miniflare | null;

let remoteProxySessionDetails: Awaited<
ReturnType<typeof experimental_maybeStartOrUpdateRemoteProxySession>

> | null = null;
let remoteProxySessionDetails: Awaited<ReturnType<typeof experimental_maybeStartOrUpdateRemoteProxySession>> | null = null;

async function startOrUpdateDevSession() {
remoteProxySessionDetails =
await experimental_maybeStartOrUpdateRemoteProxySession(
{
bindings: {
MY_KV: {
type: 'kv_namespace',
id: 'kv-id',
experimental_remote: true,
}
}
},
remoteProxySessionDetails
);

const miniflareOptions: MiniflareOptions = {
scriptPath: "./worker.js",
kvNamespaces: {
MY_KV: {
id: "kv-id",
remoteProxyConnectionString:
remoteProxySessionDetails?.session.remoteProxyConnectionString,
},
},
};

if (!mf) {
mf = new Miniflare(miniflareOptions);
} else {
mf.setOptions(miniflareOptions);
}
remoteProxySessionDetails = await experimental_maybeStartOrUpdateRemoteProxySession({
bindings: {
MY_KV: {
type: 'kv_namespace',
id: 'kv-id',
experimental_remote: true,
}
}
},
remoteProxySessionDetails
);

const miniflareOptions: MiniflareOptions = {
scriptPath: "./worker.js",
kvNamespaces: {
MY_KV: {
id: "kv-id",
remoteProxyConnectionString:
remoteProxySessionDetails?.session.remoteProxyConnectionString,
},
},
};

if (!mf) {
mf = new Miniflare(miniflareOptions);
} else {
mf.setOptions(miniflareOptions);
}
}

// ... tool logic that invokes `startOrUpdateDevSession()` ...
Expand Down