is `npx wrangler types` supposed to work
is
npx wrangler types
supposed to work for workflows?
wrangler.toml: services = [{ binding = "WORKFLOW_PROCESS_TRANSACTIONS", service = "money" }]
wrangler version: wrangler 3.107.3
generated interface, WORKFLOW_PROCESS_TRANSACTIONS should be Workflow?
15 Replies
It feels like the guides are super targeted at going from scratch. I'm adding them into my remix app on pages
It's also highly possible I'm doing it wrong, trying to follow this: https://developers.cloudflare.com/workflows/build/call-workflows-from-pages/
Cloudflare Docs
Call Workflows from Pages · Cloudflare Workflows docs
You can bind and trigger Workflows from Pages Functions by deploying a Workers project with your Workflow definition and then invoking that Worker using service bindings or a standard fetch() call.
1. Deploy another worker.
2. Add custom domain to it (i.e. worker.yourdomain.com)
3. Implement workflow classes, logic, etc at this worker.
4. Add binding similar as you do,
5. call it as env.WORKFLOW_PROCESS_TRANSACTIONS.fetch(url, options)
This is exactly how I make cross-worker connections and it should work from the pages as well.

After nr. 4 don't forget
npx wrangler types
Better: https://developers.cloudflare.com/workflows/build/workers-api/#cross-script-calls
you can call across to it as a Workflow. No need to fetch
Maybe. I just took this approach from the Zaraz, as it does not support the workflows directly (as its based on wranglers 3.19 or something version).
thanks for the help. @Matt I'm not looking to put it in a different worker, I want access to all the same stuff in my server (db, email-sending, types etc.).
How can I keep the workflow in the same service?
If you're using Pages, it must be in a separate service.
If you're using Workers... follow the tutorial. The default is part of the same Worker.
Ah ok. Can I bank on using 1 service in the future with the converging of workers and pages?
Should I be getting off pages altogether eventually?
It will converge on Workers (+ Static Assets) - so if you deploy that way it will just work.
The Pages binding is fairly straightforward though + you don’t need to “maintain” it.
The Pages binding is fairly straightforward though + you don’t need to “maintain” it.To make sure I'm not misunderstanding, this is deploying the separate workers service with your workflow and calling it from pages right? Not solving the problem I mentioned where all my backend code is already in my pages app? Want to make sure I'm not missing something
Correct.
Workflow = Workers. Keep your Pages app as-is. We aren't forcing you to migrate/move off Pages. You can choose to adopt Workers + Static Assets if you want it to be a monorepo.
Fair enough. Just my feedback as a user, it doesn't seem like I should keep on pages long-term. I was already missing out on cron triggers, and now this. Calling a separate app (duplicating my backend setup into a different worker) is a non-starter for my projects.
I'm not saying Cloudflare is forcing me to migrate off, but if I want the new goodies, it sounds like I should.
I don’t see how you would need to duplicate the setup?
If you're using Pages, it must be in a separate service.My workflow must be in a separate service right? So to do anything server-related don't I need the same server-related stuff that's already in my pages app? e.g. DB credentials, email template, types. To be clear, today I have a remix pages app. What I'm understanding is I can't add workflows to my service, so the recommendation is deploy a separate service with the workflow and call that from my existing service.