Vite with WorkerEntrypoint (RPC)

I'm trying to run Hono app on Vite as Cloudflare Worker. I'm using @cloudflare/vite-plugin and I'm getting following error when vite serve: Worker "core:user:minerva-gateway"'s binding "AUTH_SERVICE" refers to a service "core:user:minerva-auth", but no such service is defined. The problem might be because I use WorkerEntrypoint (to enable RPC), does Vite support it? If so, where should I define the service?
12 Replies
korinne
korinne8mo ago
Hi! Do you have something I could repro to see the error myself? I'm going to assume you're using standing up an auth service on one Worker, and trying to communicate to that Worker from another service using a service binding (via WorkerEntrypoint). Is that accurate? If so, here's an example of how to have multiple workers with the Vite plugin: https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare/playground/multi-worker Let me know if you're attempting something else, and would love to help!
GitHub
workers-sdk/packages/vite-plugin-cloudflare/playground/multi-worker...
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - cloudflare/workers-sdk
Kotkoroid
KotkoroidOP8mo ago
Thanks! That'll do.
Kotkoroid
KotkoroidOP7mo ago
@korinne I was trying to figure it out and I'm stuck at the problem that the worker cannot access the database. I have found out (https://github.com/cloudflare/workers-sdk/issues/8980) that it has to be specified in vite.config.ts but I couldn't find anything named persist in the plugin options. Would you be so kind to clarify? 🙏
GitHub
Local D1 Access Fails When Invoked via Service Binding · Issue #89...
Which Cloudflare product(s) does this pertain to? D1 What versions & operating system are you using? @cloudflare/vite-plugin v1.0.2+, Wrangler v4.11.1+ on macOs Describe the Bug I am seeing a s...
korinne
korinne7mo ago
Hi @w7a9q ! I believe it's the persistState config option you're looking for: https://developers.cloudflare.com/workers/vite-plugin/reference/api/ Hope that helps!
Cloudflare Docs
API
Vite plugin API
Kotkoroid
KotkoroidOP7mo ago
@korinne Ah, yes. Thank you! One question though, what if the "main" worker uses more than one auxiliary worker with D1 binding? Is that yet to be supported? persistState doesn't accept an array.
korinne
korinne7mo ago
Hmm good question -- meeting with the team tomorrow morning and will ask, and follow up!
Kotkoroid
KotkoroidOP7mo ago
@korinne Is there any progress regarding the issue?
korinne
korinne7mo ago
@w7a9q Sorry for the delay! I think what you're looking for is actually Dev Registry support in the Vite plugin (https://github.com/cloudflare/workers-sdk/issues/8963 ) which is currently being worked on!
GitHub
vite plugin multi workers with dev-registry · Issue #8963 · cloud...
Describe the solution Currently using wrangler dev you can run multiple workers by running a separate wrangler dev command for each worker and they can still interact with each other via RPC and fe...
Kotkoroid
KotkoroidOP7mo ago
Thank you so much
korinne
korinne7mo ago
Of course!
Kotkoroid
KotkoroidOP6mo ago
@korinne Hi, fyi, dev registry has not resolved the issue. I have created an issue on GitHub: https://github.com/cloudflare/workers-sdk/issues/9511
GitHub
Vite plugin does not allow for more than one services with D1 bindi...
What versions & operating system are you using? Wrangler 4.18.0 Please provide a link to a minimal reproduction No response Describe the Bug Consider following wrangler.jsonc configuration, whi...
korinne
korinne6mo ago
@Kotkoroid Ah, I'm sorry to hear that -- thank you for filing an issue! Will look into it

Did you find this page helpful?