wrangler-legacy
wrangler-legacy copied to clipboard
wrangler unexpected behaviour on wsl
🐛 Bug report
Describe the bug
wrangler cli is really unpredictable on wsl2. I have tried it on Ubuntu and Fedora and in both instances the cli wasn't working as expected.
I was unable to use wrangler login
on all distros and it produced an error caused by operation timed out
wrangler generate ...
also doesn't work but cargo generate
the tool the wrangler use to generate the project works just fine
wrangler config
was my only way to configure wrangler on Ubuntu but it failed on Fedora
wrangler whoami
also failed on Fedore with an error: Error: ⚠️ Error: error sending request for url (https://api.cloudflare.com/client/v4/user): operation timed out
wrangler dev
and wrangler publish
work fine on Ubuntu but fails on Fedora.
Environment and versions
- operating system: Ubuntu 20.10, Kernel: 5.4.72-microsoft-standard-WSL2
- output of
wrangler -V
: wrangler 1.17.0 - output of
node -v
: v16.2.0 - content of
wrangler.toml
:
name = "helloworld" type = "webpack" account_id = "xxxxXXXXXxxxxxXXXXXxxxXXX" workers_dev = true route = "" zone_id = ""
Hi @snxk - thanks for filing this. Can you confirm that in the cases where wrangler
failed, you are otherwise able to make an API call to cloudflare from the WSL instance?
e.g. (using your own EMAIL and KEY)
user@wsl2 $ curl "https://api.cloudflare.com/client/v4/user" \
-H "X-Auth-Email: ${EMAIL}" \
-H "X-Auth-Key: ${KEY}" \
-H "Content-Type: application/json"
@nilslice on running the curl command I am getting an error :
{"success":false,"errors":[{"code":6003,"message":"Invalid** request headers","error_chain":[{"code":6103,"message":"Invalid format for X-Auth-Key **header"}]}],"messages":[],"result":null}
I did some digging and was able to get a successful response by:
curl "https://api.cloudflare.com/client/v4/user" \
-H "X-Auth-Email: ${EMAIL}" \
-H "Authorization: Bearer ${KEY}" \
-H "Content-Type: application/json"
Ok, thank you for trying the other auth style!
Hm.. would you be able to re-run your failing wrangler commands like so:
RUST_LOG=debug wrangler <command>
You will see a bunch of additional output, please copy/paste it here (if you're ok to share), removing anything sensitive in case it is printed.
On running RUST_LOG=debug wrangler login
[2021-06-23T05:23:40Z INFO wrangler::settings::global_config] No $WRANGLER_HOME detected, using $HOME
Allow Wrangler to open a page in your browser? [y/n]
y
💁 Opened a link in your default browser: https://dash.cloudflare.com/wrangler?key=${KEY}
[2021-06-23T05:23:42Z DEBUG eventual::core] Core::producer_ready; state=State[count=0; consuming=false; producing=false; lifecycle=New]
[2021-06-23T05:23:42Z DEBUG eventual::core] - transitioned from State[count=0; consuming=false; producing=false; lifecycle=New] to State[count=0; consuming=false; producing=false; lifecycle=ProducerWait]
⠁ Waiting for API token...
[2021-06-23T05:23:42Z DEBUG eventual::core] Core::consumer_await
[2021-06-23T05:23:42Z DEBUG eventual::core] Core::consumer_ready; state=State[count=0; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-06-23T05:23:42Z DEBUG eventual::core] Core::consumer_wait; state=State[count=0; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-06-23T05:23:42Z DEBUG eventual::core] - transitioned from State[count=0; consuming=false; producing=false; lifecycle=ProducerWait] to State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait]
[2021-06-23T05:23:42Z DEBUG eventual::core] - notifying producer
[2021-06-23T05:23:42Z DEBUG eventual::core] Core::notify_producer
[2021-06-23T05:23:42Z DEBUG eventual::core] - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait] to State[count=1; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-06-23T05:23:42Z DEBUG eventual::core] - Invoking producer; state=State[count=1; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-06-23T05:23:42Z DEBUG eventual::stream] Sender::poll; is_ready=true
[2021-06-23T05:23:42Z DEBUG eventual::core] Core::producer_poll; state=State[count=1; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-06-23T05:23:42Z DEBUG syncbox::thread_pool] running task; tp-state=Running; worker_count=0
[2021-06-23T05:23:42Z DEBUG syncbox::thread_pool] spawning new worker thread
[2021-06-23T05:23:42Z DEBUG syncbox::thread_pool] task submitted to queue
[2021-06-23T05:23:42Z DEBUG syncbox::thread_pool] worker waiting for task
[2021-06-23T05:23:42Z DEBUG eventual::core] - Producer invoked; state=State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait]
⠒ Waiting for API token...
[2021-06-23T05:23:43Z DEBUG syncbox::thread_pool] worker processing task
[2021-06-23T05:23:43Z DEBUG syncbox::thread_pool] ~~ running scheduled task
[2021-06-23T05:23:43Z DEBUG eventual::core] Core::complete; state=State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait]; success=true; last=false
[2021-06-23T05:23:43Z DEBUG eventual::core] - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ConsumerWait] to State[count=1; consuming=false; producing=false; lifecycle=Ready]
[2021-06-23T05:23:43Z DEBUG eventual::core] - notifying consumer
[2021-06-23T05:23:43Z DEBUG eventual::core] Core::consumer_await - unparking thread
[2021-06-23T05:23:43Z DEBUG eventual::core] - consumer notified
[2021-06-23T05:23:43Z DEBUG eventual::core] Core::consumer_poll; state=State[count=1; consuming=true; producing=false; lifecycle=Ready]
[2021-06-23T05:23:43Z DEBUG eventual::core] - transitioned from State[count=1; consuming=false; producing=false; lifecycle=Ready] to State[count=1; consuming=false; producing=false; lifecycle=New] (consuming value)
[2021-06-23T05:23:43Z DEBUG eventual::core] Core::producer_ready; state=State[count=1; consuming=false; producing=false; lifecycle=Ready]
[2021-06-23T05:23:43Z DEBUG eventual::core] - transitioned from State[count=1; consuming=false; producing=false; lifecycle=New] to State[count=1; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-06-23T05:23:43Z DEBUG syncbox::thread_pool] worker waiting for task
⠦ Waiting for API token...
[2021-06-23T05:23:44Z DEBUG reqwest::async_impl::client] response '404 Not Found' for https://api.cloudflare.com/client/v4/workers/token
[2021-06-23T05:23:44Z DEBUG eventual::core] Core::consumer_await
[2021-06-23T05:23:44Z DEBUG eventual::core] Core::consumer_ready; state=State[count=1; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-06-23T05:23:44Z DEBUG eventual::core] Core::consumer_wait; state=State[count=1; consuming=false; producing=false; lifecycle=ProducerWait]
[2021-06-23T05:23:44Z DEBUG eventual::core] - transitioned from State[count=1; consuming=false; producing=false; lifecycle=ProducerWait] to State[count=2; consuming=false; producing=false; lifecycle=ConsumerWait]
[2021-06-23T05:23:44Z DEBUG eventual::core] - notifying producer
[2021-06-23T05:23:44Z DEBUG eventual::core] Core::notify_producer
[2021-06-23T05:23:44Z DEBUG eventual::core] - transitioned from State[count=2; consuming=false; producing=false; lifecycle=ConsumerWait] to State[count=2; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-06-23T05:23:44Z DEBUG eventual::core] - Invoking producer; state=State[count=2; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-06-23T05:23:44Z DEBUG eventual::stream] Sender::poll; is_ready=false
[2021-06-23T05:23:44Z DEBUG eventual::core] Core::producer_poll; state=State[count=2; consuming=false; producing=true; lifecycle=ConsumerWait]
[2021-06-23T05:23:44Z DEBUG syncbox::thread_pool] running task; tp-state=Running; worker_count=1
[2021-06-23T05:23:44Z DEBUG syncbox::thread_pool] spawning new worker thread
[2021-06-23T05:23:44Z DEBUG syncbox::thread_pool] task submitted to queue
[2021-06-23T05:23:44Z DEBUG syncbox::thread_pool] worker waiting for task
[2021-06-23T05:23:44Z DEBUG eventual::core] - Producer invoked; state=State[count=2; consuming=false; producing=false; lifecycle=ConsumerWait]
⠲ Waiting for API token...
it's stuck there and results in a request timeout.
wrangler generate
also timed out
[2021-06-23T05:31:25Z INFO wrangler::settings::global_config] No $WRANGLER_HOME detected, using $HOME
[2021-06-23T05:31:25Z INFO wrangler::cli::generate] Generate command called with template https://github.com/cloudflare/worker-template, and name my-cloudflare-worker
[2021-06-23T05:31:25Z INFO wrangler::commands::generate] Generating a new worker project with name 'my-cloudflare-worker'
⬇️ Installing cargo-generate v0.5.0...
[2021-06-23T05:31:25Z INFO wrangler::install] prebuilt artifact https://workers.cloudflare.com/get-binary/ashleygwilliams/cargo-generate/v0.5.0/x86_64-unknown-linux-musl.tar.gz
[2021-06-23T05:31:25Z DEBUG reqwest::connect] starting new connection: https://crates.io/
[2021-06-23T05:31:55Z DEBUG wrangler::version] could not determine if update is needed:
error sending request for url (https://crates.io/api/v1/crates/wrangler): operation timed out
I think that wrangler generate
fails when I use npm to install the cli, if I use cargo to install wrangler the generate commands works.
Thank you. That is quite strange. I wonder if there is anything going on with the system SSL bindings. I will need to do some testing on WSL & get back to you.
I was able to reproduce the wrangler login
error, but only if my session on https://dash.cloudflare.com was inactive. Can you check if this is also true in your case?
If you log in to the Cloudflare dashboard before executing wrangler login
and the browser window launched by wrangler shares the same browser session, it should work.
I ran wrangler login
when I am already logged in on https://dash.cloudflare.com
I got
Allow Wrangler to open a page in your browser? [y/n]
y
💁 Opened a link in your default browser: https://dash.cloudflare.com/wrangler?key={KEY}
⠁ Waiting for API token...
I think it's an issue with OpenSSL and how it is implemented in WSL. For now, wrangler config
is the only way to link my Cloudflare account with wrangler CLI.
Had similar errors a while back, seemed totally odd as other things worked. Also had almost no issues at home network, but at a friends place it was all about these errors. We figured out it was something network related, seemed almost like it was due to ipv6 being used on the friends network, but not fully sure.
Resolved the issues by doing a full network adapter reset, these are the steps:
- Run powershell/cmd as administrator.
- Run:
wsl --shutdown
. - Run:
netsh winsock reset
. - Run:
netsh int ip reset all
. - Run:
netsh winhttp reset proxy
. - Run:
ipconfig /flushdns
. - Hit WIN + Q.
- Enter
Network Reset
. - Hit ENTER .
- Click
Reset now
. - Restart.
https://github.com/cloudflare/wrangler/issues/2101 seems to be the same issue
👋 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.