wrangler-legacy icon indicating copy to clipboard operation
wrangler-legacy copied to clipboard

`dev` fails with a websocket redirect error

Open viraptor opened this issue 3 years ago • 4 comments

🐛 Bug Report

Environment

  • operating system: macos
  • output of rustc -V: 1.47.0
  • output of node -v: v14.15.1
  • output of wrangler -V: 1.12.3 / master
  • contents of wrangler.toml
name = "service_id"
type = "webpack"
account_id = "..."
workers_dev = true
route = "some_domain.net/*"
zone_id = "..."

kv_namespaces = [
  { binding = "KV", id = "...", preview_id = "..." }
]

Steps to reproduce

wrangler dev

What did you expect to see?

Service to start up

What did you see instead?

thread 'tokio-runtime-worker' panicked at 'Failed to connect to devtools instance: Http(302)', src/commands/dev/socket.rs:30:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
👂  Listening on http://127.0.0.1:8787
Error: panic

This is triggered in src/commands/dev/socket.rs:28 / wrangler::commands::dev::socket::listen::{{closure}}

Unfortunately due to tokio-tungstenite returning only the status, I don't know exactly what the contents are. It may be related however due to us using access authentication on the domain. If I print out the url wrangler is trying to connect to (https://some_domain.net/cdn-cgi/workers/preview/inspector?f_workers_preview_token=...) and try to curl it, I can see:

< HTTP/2 302
...
< location: https://....cloudflareaccess.com/cdn-cgi/access/login/some_domain.net

which I expect is the same redirect wrangler sees.

viraptor avatar Jan 06 '21 04:01 viraptor

I was able to work around this issue by not simultaneously specifying both zone_id and workers_dev when running wrangler dev.

A configuration like this works:

name = "service_id"
type = "webpack"
workers_dev = true
account_id = "..."

kv_namespaces = [
  { binding = "KV", id = "...", preview_id = "..." }
]

[env.prod]
workers_dev = false
route = "some_domain.net/*"
zone_id = "..."

lukevalenta avatar Mar 11 '21 19:03 lukevalenta

This issue has been automatically marked as stale because it has not had recent activity in the last 180 days. It will be closed if no further activity occurs in the next week. Please feel free to comment if you'd like it to remain open, and thank you for your contributions.

stale[bot] avatar Sep 19 '21 20:09 stale[bot]

Stay away, bot!

viraptor avatar Sep 22 '21 22:09 viraptor

We made some updates to websocket support.. is this still an issue?

jgentes avatar Dec 28 '21 18:12 jgentes

Thanks for reporting this issue! Wrangler v1 is now deprecated and support is only being provided for critical updates or security concerns. As such, we are closing this issue. New versions of Wrangler are maintained in the workers-sdk repo. If you are running into a similar issue with wrangler v2, please report it in the workers-sdk repo. For more info about wrangler v1 deprecation, please check out our blog post.

jspspike avatar Feb 27 '23 16:02 jspspike