Miniflare – Simulator for developing and testing Cloudflare Workers
github.com
github.com
I've had nothing but problems with it.
- Terrible console.log() messages. I had to resort to using JSON.stringify for anything other than primitive values.
- Timeout errors when using wrangler dev on workers that work perfectly when deployed.
- Wrangler dev just crashing frequently or being super slow at reloading the worker.
Overall we're working hard on making this experience better, please feel free to file issues if you see anything that's not expected. Thank you!
Workers are great once they are deployed, but the DX is abismal...
What kind of issues did you have ?
Stay tuned, things should get better soon.
Happy to see miniflare now :)
And of course, miniflare reduces even the chance of that to zero :)
- It's not relevant now but I couldn't figure out how to connect cloudflared with wrangler tail on windows. Wrangler tail points to the cloudflared docs but the cloudflared docs doesn't mention wrangler at all. I was pretty lost for what to do.
- [Not relevant] I haven't investigated this properly but Promise.then.catch doesn't seem to work? async/await works though.
- I'm pretty sure URL.createObjectURL in this example [1] doesn't work on the worker.
- Wrangler dev doesn't have the request.cf object. I see why but a dummy one would be cool.
None is deal-breaker but they wear you down when you walk through the documentation.
[0] https://community.cloudflare.com/t/fetch-in-worker-strips-po...
[1] https://developers.cloudflare.com/workers/examples/read-post
Thanks for the feedback!
It sounds like you may be thinking of `wrangler preview`, not `wrangler dev`. `wrangler preview` runs the worker on a service that operates outside Cloudflare infrastructure, so a lot of things aren't realistic, like support for host+port and request.cf. `wrangler dev` runs the worker inside the real Cloudflare stack on the real edge, which should solve those problems. Our plan is to sunset `wrangler preview` in favor of `wrangler dev`.
> It's not relevant now but I couldn't figure out how to connect cloudflared with wrangler tail on windows.
Good news, this has been fixed recently -- `wrangler tail` no longer requires `cloudflared`.
> - I haven't investigated this properly but Promise.then.catch doesn't seem to work? async/await works though.
Promises are implemented inside V8, so they should work exactly the same on Workers as in Chrome and Node. I'd love to see an example of what's not working if you have one.
> - I'm pretty sure URL.createObjectURL in this example [1] doesn't work on the worker.
This is indeed an API we don't support, and realistically we probably can't support. I'd be interested to understand your use case for this.
Ah sorry, I was confusing stuffs. It wasn't even wrangler preview, it was the web editor on the worker website.
> cloudflared
Yep, I noticed that update. I couldn't have updated wrangler faster.
> Promise.then
I'm sorry again. False alarm. It's me not understanding when things get executed.
> URL.createObjectURL
I don't really have a use case for it. It was mostly me seeing the example code being reasonable, copied it and was surprised it didn't work.
Only workers created with wrangler generate work.
I opened this issue and never received an answer:
https://github.com/cloudflare/wrangler/issues/2077
I closed it because wrangler dev still works with generate, so I assumed it was a problem on my end.
It still sucks that it just stopped working for no reason.
`wrangler login` doesn't work if I'm not already logged in to CloudFlare website. If I have to login first, it doesn't do whatever necessary redirect it should do so most of the time I have to run `wrangler login` twice.
`wrangler dev` is slow.
`wrangler dev` requires root domain. https://github.com/cloudflare/wrangler/issues/1529
I also feel that the interaction between DNS settings and workers is under-documented, probably because it crosses responsibility of two different teams.
For example, it took me way too long to figure out that if I have a workers-only website for foo.bar.org, I have to put dummy DNS entry for foo.bar.org
Frankly, despite reading wrangler docs multiple times, I don't think I fully understand the interactions between what's in the DNS, what's in the workers route and further more if you add pages to the mix.
Docs should explicitly spell out DNS / routes setup for most common scenarios like: 1) workers-only site (no proxying to any other server) 2) workers in front of a proxied website
Workers should be seamlessly integrated with pages i.e. pages should just automatically recognize and use workers-site/ directory on deploy.
I don't think setting up pages automatically configures DNS settings for its domain, which it obviously should (might be mis-remembering).
- > `wrangler login` doesn't work if I'm not already logged in to CloudFlare website This should be fixed in our last release!
- `wrangler dev` is slow. Agreed. We're working on making it faster, but miniflare is a great option for the fastest dev experience at the moment.
- Regarding DNS/domains/Workers, this is all great feedback. We should be making this more painless/intuitive. We'll work on it!
Could you add a validate switch? Something I can integate into a CI pipeline that basically takes a look at whether it is a valid CF worker. Obviously running a linter over it already but presumably there are CF specific checks that could be added. Thanks
A very basic rudementary static code analysis that can check whether this is a valid CF worker configuration.
>Could you share more detail about your usecase?
In a CI configuration like gitlab CI. e.g. Currently I'm using an incredibly hacky setup that loads the function into miniflare locally, hits then endpoint with a curl and checks that it comes back with 200 HTTP.
If yes then assumption is that it's sound & next stage of CI can actually deploy the function.
Not super high priority though - please prioritise other requests above this since I've already got a working duct tape fix for my problem
https://github.com/gja/cloudflare-worker-local/commit/ce6004...
That reflects extremely well both on this repo as well as cloudflare.