Recommended way of registering a Durable Object
hey people! what's the recommended way of registering a Durable Object when deploying an application (Remix) using Cloudflare Pages. Do I need to create a separate project just to deploy that? or can it be wihtin the Cloudflare Pages repo? I've seen an example using
/durable_objects
to register a Durable Object within a Pages repo but I'm unable to get it listed in the Cloudflare Dashboard. What am I missing?8 Replies
this is what I have in my
wrangler.toml
hey! you're quite close - there's just one limitation of Pages that you've run into
So Pages doesn't actually read your wrangler.toml, and Pages projects can't "define" Durable Objects, you need a separate worker. Examples that have it in a subfolder deploy
/durable_objects
as a separate Worker and bind to its DO from the Pages dashboardhow I'm I supposed to deploy this
/durable_objects
directory? with wrangler deploy
command? maybe some link I can read about what I'm missing, would be excellent
thanks for this! It's already very explanatory
I found this one. Is it up to date? https://blog.cloudflare.com/building-full-stack-with-pages/Hang on, isn't pages supposed to have "functions" which are the equivalent of workers? It was my understanding that in Remix code what is declared as loader and action functions will be converted to functions and will behave as a worker would. Is this not the case?
It is the case, in 99.9% of the cases. Pages Functions can't declare queue consumers or define Durable Object classes. Everything else should work (assuming it has support in Pages, which is the case for most bindings, other than 1-2 newer ones)
Thanks, glad to hear that. I think it's a bit less than 99.9%. The big issue I run into is that Pages functions don't have a global context like Workers do. Hence accessing context via environment variables, as in KV, Durable Objects, etc. becomes an issue.
is it true that's being developed a way of unifying how to consume Cloudflare services? this is just curiousity
following up with the question, I was able to deploy my Durable Object. I'll give you my full information because I can't seem to find the solution
this is the standalone Worker I created to be able to upload the Durable Object
I leave an image of the structure of the Worker, it's completely isolated from my Remix app
these are the scripts I'm testing locally
and I'm getting this error
![No description](https://cdn.answeroverflow.com/1173983424118280192/Screenshot_2023-11-14_at_10.48.44.png)
this is the complete Durable Object, which I wasn't able to paste in the last message
sorry for the long message, but here is all the information. What am I missing?
update: it works on
production
. It's just the local development that's NOT working
so close