Hacker News new | ask | show | jobs
by squaresmile 1723 days ago
- [Not relevant] There's this limitation about fetching host+port [0] in the worker. It works fine in wrangler dev but doesn't work on Cloudflare worker. I don't mind that it's a limitation of the platform but there should be documentation and wranlger dev should be consistent with the actual worker.

- 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

2 comments

Hi squaresmile,

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.

> dev/preview

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.

We should definitely not have examples on the docs that don't actually work. I'll fix this.
Do you accept PRs on the docs (at least for the examples)?
Also, every page has an "Edit on Github" link so you can go straight to the page you're seeing (in this case - https://github.com/cloudflare/cloudflare-docs/blob/productio...)
This is amazing feedback, thank you very much! I'm going to work on each of these; but quickly - we definitely shouldn't have something that works in `wrangler dev` but not in the platform, and we should warn/error on that, our docs shouldn't have examples that don't work :facepalm:, and we should be spec compliant where we can. Thank you so much!