Module Workers on Dashboard

I created a module worker which has a folder called src and bunch of files inside. I deployed it using Wrangler and tested it, it works just fine. No problem here. But when go to CF Dashboard, click on Workers > Manage Workers > the module worker > Quick Edit I see two problems:

1- I cannot see my files. It shows an empty page on the left side, where source code is supposed to be. I know it is not only one file but multiple files, but here says that Module Workers are supported in the dashboard.
2- I see a red warning saying “script body must not be empty (Code: 10021)”. When I check network, I see that empty editor tried to send an HTTP PUT request to “/preview” endpoint with an empty body. Furthermore, I am able to type code and save & deploy, overriding the content that I cannot browse. IMO editor shouldn’t be active when it fails to load the source.

Module Workers are supported in the Dashboard Quick Edit. The issue is that Wrangler and Quick Edit are not compatible - especially if you use a tool like ESBuild to bundle multiple files into one. You have to use one or the other to manage a Worker.

I think this happens if the entry script you uploaded through Wrangler does not use the default name. I believe the default is worker.js which is what the Dashboard uses.

1 Like

You have to use one or the other to manage a Worker

I understand this. If I wanted to use Quick Edit and not use Wrangler at all, Quick Edit just lets me create only one single file. If I cannot have more files, therefore cannot use ES6 features like “import” so it doesn’t make much sense to use Quick Edit for Module Workers.

I think this happens if the entry script you uploaded through Wrangler does not use the default name. believe the default is worker.js which is what the Dashboard uses.

I tried with worker.js and got the same error. This happens because the editor tries to upload upon receiving the source regardless of what kind of content it is getting (which is multipart in this case). This looks like a mistake in the implementation which can cause people to override existing Worker codes.

With its current state, it feels like if worker code is multipart then Quick Edit page should not be accessible.

I use modules in quick edit simply because I prefer the syntax. I think the single-file limitation is by design: if you need to create elaborate Workers with multiple files, you probably should be using a local IDE and Wrangler.

I’m pretty sure it only tries to upload to the preview service. It should not deploy unless you click the “Save” button. But I may of course be wrong.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.