Skip to content
Closed
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
63 changes: 31 additions & 32 deletions src/content/docs/workers/development-testing/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -392,41 +392,40 @@ import { experimental_maybeStartOrUpdateRemoteProxySession } from "wrangler";
let mf: Miniflare | null;

let remoteProxySessionDetails: Awaited<
ReturnType<typeof experimental_maybeStartOrUpdateRemoteProxySession>

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