Access Durable Object RPC from Worker with Vite plugin
I have a worker and a durable object in a monorepo:
I have the DO referenced in my worker's wrangler.jsonc
I tried using the global env import:
But "Workers do not allow I/O from outside a request context" so that won't work.
(The actual error I get is:
But I'm not sure how to access the request context from within a vite-configured worker.
I'm also not sure that's the right way to go about this.
Should I be accessing env a different way? Should I define the DO as an auxiliary worker in the vite plugin?
- The worker is a tanstack-start app configured with the vite plugin.
- The durable object facilitates a websocket connections and stores some state in SQLite.
I have the DO referenced in my worker's wrangler.jsonc
I tried using the global env import:
But "Workers do not allow I/O from outside a request context" so that won't work.
(The actual error I get is:
Couldn't find the durable Object "WsDo" of script "ws-do" I can confirm that I am able to access the stub and can console.log the name and id of the DO, but using service bindings does not work in this context)But I'm not sure how to access the request context from within a vite-configured worker.
I'm also not sure that's the right way to go about this.
Should I be accessing env a different way? Should I define the DO as an auxiliary worker in the vite plugin?