Skip to content

Multiple config files with getPlatformProxy to support Durable Objects RPC #9445

@bgever

Description

@bgever

Describe the solution

I have a SvelteKit based framework Worker. This is using the @sveltejs/adapter-cloudflare adapter which uses Wrangler's getPlatformProxy API under the hood to provide a great DX with vite dev for local development. I'm able to use bindings to D1, KV, etc. and have hot module reloading from Vite.

When I tried to add a Durable Object binding, which I was running in a separate wrangler dev, I ran into the error:

Error: Cannot access `MyDurableObject#sayHello` as Durable Object RPC is not yet supported between multiple `wrangler dev` sessions.

Reading in the Docs, I can only do Durable Objects RPC when a single wrangler dev uses multiple configurations:
https://developers.cloudflare.com/workers/wrangler/api/#supported-bindings (related to #5918)

This would require me to build both the SvekteKit and DO workers before spinning them up in a single wrangler dev session. Therefore I would miss out on hot module reloading with Vite, significantly slowing down the DX.

Feature Request

I would like to request adding support for multiple configuration files to the getPlatformProxy API, to provide a similar solution as the multiple config files with wrangler dev.

In the svelte.config.js file, I would be able to conditionally pass in multiple config files depending on environment (local development vs production), since the SvelteKit adapter accepts a platformProxy prop on the options, which is passed to getPlatformProxy.

Currently, the getPlatformProxy options allows to specify a single config file with configPath already. Maybe this could accept an array of strings as well?

If that allows the framework worker and DO worker to communicate via RPC, then I can keep having the nice hot module reload DX with Vite, whilst depending on a Durable Object for persisted storage during development.

Metadata

Metadata

Labels

Type

No fields configured for Task.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions