Deploying to cloudflare using wrangler vite

Hello everyone, came across this project and love how it solves every pain points i have had with dos. And the option to migrate off to your own cloud and not being vendor locked was awesome. While i was a lot to deploy it using the example I wasn’t able to get it working using the Cloudflare wrangler vite plugin. Can anyone help or have a boiler plate using the vite plugin.
8 Replies
Nathan
Nathan2mo ago
hey! this is an example that's not in the examples folder, correct? https://github.com/rivet-dev/rivetkit/tree/main/examples/cloudflare-workers
GitHub
rivetkit/examples/cloudflare-workers at main · rivet-dev/rivetkit
A library for building stateful workloads anywhere - rivet-dev/rivetkit
Nathan
Nathan2mo ago
can you send an example project (vite config + wrangler config) when you have a chance
fitsumayalew
fitsumayalewOP2mo ago
Yes the example above works well but there are no examples using the Cloudflare Vite Plugin. I will setup an example project and send you soon! Thank you!
fitsumayalew
fitsumayalewOP2mo ago
Hello, sorry for taking so long here is an example setup I have based on the multiplayer game example in the rivetkit repo. https://github.com/fitsumayalew/rivetkit-game-cloudflare-workers The main issue seems to be that after calling http://localhost:5173/rivet/metadata?namespace=default it calls http://127.0.0.1:6420/actors?namespace=default but that endpoint doesn't exist Sometimes it shows this error on the terminal but couldn't figure out why it was showing some of the times and not other times
level=WARN msg="internal error" error="Function not implemented." stack="Error: Function not implemented.\n at CloudflareActorsManagerDriver.createActor (/Users/fitsum/Projects/oss/game/node_modules/.vite/deps_rivetkit_game_cloudflare_workers/@rivetkit_cloudflare-workers.js:469:5)\n at CloudflareActorsManagerDriver.getOrCreateWithKey (/Users/fitsum/Projects/oss/game/node_modules/.vite/deps_rivetkit_game_cloudflare_workers/@rivetkit_cloudflare-workers.js:451:14)\n at /Users/fitsum/Projects/oss/game/node_modules/.vite/deps_rivetkit_game_cloudflare_workers/chunk-EL5HFVGO.js:4..." issues=https://github.com/rivet-dev/rivetkit/issues support=https://rivet.dev/discord method=PUT path=/actors
level=WARN msg="internal error" error="Function not implemented." stack="Error: Function not implemented.\n at CloudflareActorsManagerDriver.createActor (/Users/fitsum/Projects/oss/game/node_modules/.vite/deps_rivetkit_game_cloudflare_workers/@rivetkit_cloudflare-workers.js:469:5)\n at CloudflareActorsManagerDriver.getOrCreateWithKey (/Users/fitsum/Projects/oss/game/node_modules/.vite/deps_rivetkit_game_cloudflare_workers/@rivetkit_cloudflare-workers.js:451:14)\n at /Users/fitsum/Projects/oss/game/node_modules/.vite/deps_rivetkit_game_cloudflare_workers/chunk-EL5HFVGO.js:4..." issues=https://github.com/rivet-dev/rivetkit/issues support=https://rivet.dev/discord method=PUT path=/actors
And it also has this error when deploying
✘ [ERROR] A request to the Cloudflare API (/accounts/ece998c8a5126340808285bcb9185d82/workers/scripts/rivetkit-game-cloudflare-workers) failed.

Uncaught Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or
connect()), setting a timeout, and generating random values are not allowed within global scope.
To fix this error, perform this operation within a handler.
✘ [ERROR] A request to the Cloudflare API (/accounts/ece998c8a5126340808285bcb9185d82/workers/scripts/rivetkit-game-cloudflare-workers) failed.

Uncaught Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or
connect()), setting a timeout, and generating random values are not allowed within global scope.
To fix this error, perform this operation within a handler.
Let me know if there is any other way I can help!
GitHub
GitHub - fitsumayalew/rivetkit-game-cloudflare-workers
Contribute to fitsumayalew/rivetkit-game-cloudflare-workers development by creating an account on GitHub.
Nathan
Nathan2mo ago
Hey! Some folks are reporting issues with the most recent Cloudflare driver. We're working on fixing it today.
fitsumayalew
fitsumayalewOP2mo ago
Awesome will check back after it is fixed then 🙌
Nathan
Nathan2mo ago
@fitsumayalew give v2.0.15 a try – thanks for the patience!
fitsumayalew
fitsumayalewOP2mo ago
It works very smoothly 🔥 can't wait to explore it more. This setup looks so good. Keep doing the great work!

Did you find this page helpful?