stripe / stripe-cli

A command-line tool for Stripe
https://stripe.com/docs/stripe-cli
Apache License 2.0
1.6k stars 374 forks source link

After upgrading on wsl2, stripe command hangs #970

Open RhysLees opened 2 years ago

RhysLees commented 2 years ago

Issue

After Upgrading to the latest version, stripe-cli no longer works.

Rolling back to 1.8.11 works fine (havent checked newer versions)

Expected Behaviour

N/A

Steps to reproduce

Install stripe-cli latest version on wsl2 and run "stripe" the command will hand. you can also pass "stripe -v" which hangs along with any other command

Traceback

No output

Environment

Windows 11 -> WSL2 Ubuntu Latest version

astlouisf commented 2 years ago

It seems like the first version that hangs on WSL2 is 1.10.4. We only ran stripe --help to determine whether a specific version hangs.

RhysLees commented 2 years ago

It seems like the first version that hangs on WSL2 is 1.10.4. We only ran stripe --help to determine whether a specific version hangs.

I'll test this aswell when I'm home, but --help hangs for me aswell when I originally posted the bug

Carlwirkus commented 1 year ago

I have the same issue, stripe v1.12.4 takes >1min to do any command (including --help). Downgrading to v1.10.0 works for the time being.

Qualzz commented 1 year ago

Same issue. Sometimes it can takes up to several minutes. Only way is to restart WSL and then stripe works again fine.

I confirm that 1.10.0 does works as mentionned by @Carlwirkus

charliecruzan-stripe commented 1 year ago

small update: unfortunately, we haven't been able to reproduce this so far (using WSL2 on both Windows 10 and 11)

for folks that are reverting to 1.10.0- is that because 1.10.3 is also hanging for you? it was mentioned above that 1.10.4 is the first version that hangs on WSL2 so it'd be great to be able to confirm the exact version where this hanging starts to occur for folks

Carlwirkus commented 1 year ago

Hey, thanks for the response.

The issue occurs for me with 1.10.4. 1.10.3 works. I also tried updating to latest again and I still have the issue. Let me know if there's anything else I can help with to diagnose the issue.

astlouisf commented 1 year ago

@charliecruzan-stripe If it was not clear, on our end we tested both 1.10.4 and 1.10.3 and found 1.10.4 to be broken and 1.10.3 to be working.

RhysLees commented 1 year ago

@charliecruzan-stripe I just rolled back to a version I knew worked, I never tested 1.10.3

Masterxilo commented 1 year ago

same problem here, stripe cli version 1.13.5, running WLS with Ubuntu 20.04 on Windows 11 x64.

It seems that after a few minutes of hanging, the stripe cli does something, then hangs again. Though I have the feeling for example the listen command never receives any events.

Here, you see that it takes 2 min to find the config then another 2 min to start listening:

$ date ; stripe listen --log-level=debug --load-from-webhooks-api --forward-to localhost:8081
Fri Nov 25 22:01:15 CET 2022
[Fri, 25 Nov 2022 22:03:15 CET] DEBUG config.Config.InitConfig: Using profiles file path=/home/ubuntu/.config/stripe/config.toml
[Fri, 25 Nov 2022 22:05:16 CET] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣟ Getting ready...[Fri, 25 Nov 2022 22:05:17 CET] DEBUG stripeauth.Client.Authorize: Got successful response from Stripe default_version=2022-11-15 display_connect_filter_warning=false latest_version=2022-11-15 reconnect_delay=246 websocket_authorized_feature=webhook-payloads websocket_id=*******3 websocket_url=wss://stripecli-ws-nw.stripe.com/subscribe/*******33
[Fri, 25 Nov 2022 22:05:17 CET] DEBUG websocket.client.Run: Attempting to connect to Stripe
[Fri, 25 Nov 2022 22:05:17 CET] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripecli-ws-nw.stripe.com/subscribe/****3?websocket_feature=webhook-payloads
⣯ Getting ready...[Fri, 25 Nov 2022 22:05:18 CET] DEBUG websocket.client.connect: Connected!
[Fri, 25 Nov 2022 22:05:18 CET] DEBUG Setting read deadline:
> Ready! You are using Stripe API Version [2022-11-15]. Your webhook signing secret is ************* (^C to quit)
[Fri, 25 Nov 2022 22:05:20 CET] DEBUG websocket.Client.writePump: Sending ping message
Masterxilo commented 1 year ago

Restarting wsl did not fix it (maybe stripe version was a bit faster after it though?).

This fixes the problem:

sudo apt-get remove -y stripe
sudo apt-get install -y stripe==1.10.3

$ stripe version
stripe version 1.10.3
A newer version of the Stripe CLI is available, please update to: v1.13.5

bottom line seems to be so far: everything after Stripe CLI 1.10.3 hangs on WSL...

ntountasakis commented 1 year ago

I experienced this issue on v1.13.6 and v1.13.5 running wsl2 ubuntu. Downgrading at the suggestion of a Stripe employee to a version predating 1.10 worked (v1.9.0)

Omegastick commented 1 year ago

bottom line seems to be so far: everything after Stripe CLI 1.10.3 hangs on WSL...

Confirming this. Would be nice to have a fix, since it seems like CLI 1.10 might not be able to do checkout.session.complete webhook triggers.

wreality commented 1 year ago

Starting in 1.10.4, after running the stripe command on WSL2, gnome-keyring-daemon has been started and subsequent runs of the stripe command then hang.

image

In 1.10.3 after running the stripe command on WSL2, gnome-keyring-daemon isn't running. Subsequent runs of the stripe command work just fine.

In 1.10.4 we start using a keyring.

image

My guess is that whatever that library is using to detect if the platform is cli linux is not robust enough since GUI support was added to WSL2. (Is it possible that it's not been replicatable bc the version of WSL used to try to replicate it is pre WSL gui support ?

I have no idea if this helps, but I thought I'd share what I'd found.

lucascyrne commented 1 year ago

Guys, I'm on a big rush here in a way I'll allow myself to copy/paste this question/commentaries I've done on Stripe Discord in hope someone here can provide me some directions:

Hello Stripe crew! Good morning from Brazil!

I've seen that currently there's somekind of issue (https://github.com/stripe/stripe-cli/issues/970) around using "stripe-cli" on WSL. While there's no workaround on that, how can I use stripe-cli as a wsl user? That's my first and main question.

Besides that, I would like to mention that this journey of mine begun after I realized that my Firestore (Firebase) database wasn't listing my products from my stripe account (on test mode). I'm currently trying to get around this whole situation following this tutorial: https://dev.to/perennialautodidact/connecting-stripe-webhooks-to-firebase-cloud-functions-on-localhost-using-localtunnel-55o9#setting-up-localtunnel

If you guys knows better way to connect Stripe and Firebase on localhost (dev environment), please I do ask to enlighten me. It would be great if this local connection between Stripe and Firebase could happen under the hood as the production-side as well.

I'm very optimistic about being using Stripe payment solutions in my apps and of course, be able to test it correctly before deploy it on production environment would be extremely necessary.

Much thanks in advance! 🙂

petebytes commented 1 year ago

same issue stripe commands hang after upgrading. using sudo stripe works, but I have not been able to determine why?

petebytes commented 1 year ago

just confirmed that the last version which does not require sudo is 1.10.3

pgoiporia commented 1 year ago

I ran into the same issue on wsl. Had to install stripe 1.10.3 to get it to work.

huntabyte commented 1 year ago

I was able to resolve the hanging issue by disabling guiApplications in WSL.

.wslconfig

[wsl2]
guiApplications=false
kalleth commented 1 year ago

tl;dr: If you have an X environment installed in your WSL, either disable graphical environments entirely (@huntabyte 's suggestion, above) or boot up the X server instance on your windows host (vcxsrv/xserve) so that the X environment is running, before executing the stripe CLI.

Diagnosis

I'm experiencing the same problem -- stripe --help hangs for multiple minutes (1.14.0) on wsl2 / ubuntu 20.04. The command does eventually complete, but it's incredibly slow.

Running strace -o strace.log stripe --help and tailing the file shows the process hanging on:

trussell@miller:~$ tail -f ~/strace.log
clone(child_stack=NULL, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 18759
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(11)                               = 0
read(10, "", 8)                         = 0
close(10)                               = 0
close(3)                                = 0
epoll_ctl(4, EPOLL_CTL_DEL, 9, 0xc0000bf604) = 0
close(9)                                = 0
futex(0xc00007c548, FUTEX_WAKE_PRIVATE, 1) = 1
waitid(P_PID, 18759,

Process 18759 is dbus-launch:

trussell@miller:~/Projects/website$ ps aux | grep 18759
trussell 18759  0.0  0.0   6952  1352 pts/3    S+   14:20   0:00 dbus-launch

Googling for dbus-launch hangs wsl gives me https://github.com/microsoft/WSL/issues/3039 -- which indicates that there is a link with VcXSrv (which would explain why @huntabyte 's solve of disabling gui applications entirely would work). I have VcXSrv installed so that cypress tests can be run interactively -- so I do have a gui environment installed in my WSL2.

I then tried strace -o strace.log stripe login --interactive which I would expect to avoid the need to launch anything, but:

waitid(P_PID, 19303,

(and process 19303 is, once again, dbus-launch). So, if you have a graphical environment available (whether you're using it or not!) stripe-cli is still attempting to launch something.

All of this was without the associated VcXSrv executable running on the windows host.

As a final check, I launched VcXSrv on my windows host, before trying to run the stripe CLI again. The command immediately worked straight away, no delay or "hang" - but no window appears (as expected with the --interactive flag).

Edit: The plot thickens - it does seem to be keyring related

Looks like @wreality was on to something - after authenticating using stripe login with a running X server (no --interactive this time) I get this popup:

image

Summary (edited)

So, it would appear that the bug here is that even when using the --interactive flag (or just running --help!) the stripe CLI is trying to access or set up a new keyring with GPG, which then if you have an X environment tries to interact with the X $DISPLAY (even if nothing is to be displayed!), and, because it can't if you're not actually running the X server, it can't do so.

Cremesis commented 1 year ago

Will this bug ever be fixed? I confirm 1.10.3 works normally, latest version doesn't. Windows 11, WSL 2.

jphackgen commented 1 year ago

My strace output was very different from @kalleth, so I wasn't able to bypass the hanging using 'vcxsrv'. (Or maybe I just don't know how to use vcxsrv.) Instead I found a very weird yet interesting way to bypass the lag.

Step 1.

Download MobaXterm on Windows 11 from here. Then, start your wsl by clicking on it. In my case, it was "WSL-Ubuntu-18.04".

image

Step 2.

Run export DISPLAY=`hostname`.mshome.net:0.0

image

Step 3.

Run any stripe cli command.

Step 4.

A popup appears saying wsl wants to access X server; do you want to allow it?

Press No

In my case, popup appeared again with the same message, so I pressed No again.

image image Voilà! Stripe cli (version 1.17.2.) worked without any lag...

I feel like there should be better solution that doesn't involve MobaXterm because what stripe cli wants to do is just have access to X server. But, I think I'll just stick to this for now since it works with minimum setup.

Crisfole commented 4 months ago

Ew. Super gross. Had the same issue, had to read to the bottom of this to realize it was failing because it wanted an X-Server that I didn't typically run except in specific situations.

For me I already had my system setup for X410, so starting it worked transparently, even though it didn't use the UI 🤮. It's been a few years Stripe, can we get this looked at?

4ndrs commented 3 months ago

I'm having the same issue but on Gentoo Linux with stripe_1.20.0_linux_x86_64.tar.gz. Downgrading to version 1.10.3 makes it run without hanging.