I have been trying to develop a very simple website using contentful and pugjs to display articles all generated by a CF worker on the fly. First I am not sure it is a valid use case for a CF worker but at least I have understood it is possible from the documentation.
So, the project is using: pugjs for the templating, contentful for the headless cms, cloudworker-router to manage some specific routes. From the main index.js file, a css file using tailwind is generated. Everything works fine at first when doing a wrangler dev.
Now, let’s me share my dev experience …
- Any changes on a files are detected with a delay of 3s - There is only 20 files in the src folder. Once the change is detected, I have to wait another 4s to have
Built successfully, built project size is 344 KiB. Script modified; context reset.and another few sec to upload the file into CF. => feedback loop is too long (same behaviour OSX and inside Vagrant)
- Once the build is updated, I try to refresh the page, I get an JS error in the terminal
Uncaught (in response) Error: internal errordue to
Worker exceeded resource limits. The code change is one char in the code nothing fancy. => no rational here from a dev POV, file get updated, build recreated, almost same code, but get an error.
- The other type of error I have been experimented is the new code is not being used even when wrangler says: ‘Build successfully’.
- So I have to stop wrangler and restart it at every code changes. Please note I have subscribe to the pay plan to make sure I am not hitting any kind on limitation from the free plan.
- Now, I have been trying to debug … just to understand what is causing CPU / RAM consumption. But it seems everything is in a black box. The preview feature displays a nice UI but there is very nothing much we can do, we can see the sub request, this is a nice feature, but apart from that … well nothing to help.
- I also subscribe to Argos to get more log through cloudflared. But it seems to be only access log not very helpful to debug.
- Webpack minifies and optimises the JS so trying to set a break point is almost impossible. If I set NODE_ENV to development then the compiler complains because templates cannot use EVAL. I guess webpack in dev mode does not really compile files.
- Wrangler sometime get lost, and panic but does not crash and end up with the similar behaviour states in the point 3.
Did I miss something obvious ? Does my current use case is not suitable for the current CF Worker ? Will CF Worker Unbound more appropriate ?
On the bright node, once published the code seems to running fine with no errors! I know that dev mode is pretty recent and some improvements will be made. Keep up the good work