How to test multiple workers locally

Hi, I would like to migrate from Supabase to Cloudflare and replace all my Edge functions (20+) with Workers. However, I couldn't figure how to run multiple workers locally that's accessible through the same port with different path names to call the different services. Based on the documents, it seems that I need to launch each Worker one by one in different terminals, which seems to be extremely tedious when testing an application that requires access to all the services.
2 Replies
talkingarmor
talkingarmorOP8mo ago
I see, that's quite difficult to develop then. Does that mean that people just test the functions remotely?
Magical.Puffin
Magical.Puffin7mo ago
I have been messing around with running workers using Lerna and it sort of works. There are issues when starting multiple workers in parallel so I have been using sleep statements as a workaround, "dev": "sleep 1 && wrangler dev. Edit: This was a port related issue, could just specify the local port for each worker and inspector-port https://github.com/cloudflare/workers-sdk/issues/1701 It seem like Cloudflare does recognize Lerna could be used with workers though... https://developers.cloudflare.com/workers/tutorials/manage-projects-with-lerna/
Want results from more Discord servers?
Add your server