Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pscale hangs for 2 minutes when running in WSL2 #637

Open
dbanck opened this issue Mar 20, 2023 · 12 comments
Open

pscale hangs for 2 minutes when running in WSL2 #637

dbanck opened this issue Mar 20, 2023 · 12 comments

Comments

@dbanck
Copy link

dbanck commented Mar 20, 2023

Hi!

I noticed a strange behavior when running pscale in WSL2.

  • Release 0.131.0
  • Installed via pscale_0.131.0_linux_amd64.deb
  • WSL2 Ubuntu 20.04.6 LTS

Any command will hang for 2 minutes before any output:

$ time pscale --debug org list
Updater error: skipping update, reason: Latest version was already checked
Error: not authenticated yet. Please run 'pscale auth login'
Error: --access-token is required for access token authentication

________________________________________________________
Executed in  120.11 secs      fish           external
   usr time    4.44 millis   51.00 micros    4.39 millis
   sys time    4.83 millis  114.00 micros    4.72 millis

Running pscale auth login will take 2 minutes until a browser window with the (correct) code is opened and then another ~2 minutes until a success message is shown.

$ time pscale --debug auth login
Confirmation Code: xxx

If something goes wrong, copy and paste this URL into your browser: https://auth.planetscale.com/oauth/device?user_code=xxx

Successfully logged in.

________________________________________________________
Executed in  275.68 secs      fish           external
   usr time  250.22 millis    0.00 micros  250.22 millis
   sys time  111.74 millis  770.00 micros  110.97 millis

I cannot connect to any database or do any development work in WSL2.

Happy to debug this further with some guidance.

@puregarlic
Copy link

Just chiming in to say that I'm observing this issue as well in WSL2, running the same version of Ubuntu but using pscale version 0.136.0 at time of writing. There are two details worth mentioning, though:

  1. The first command after a reboot works as expected, but every command after that takes ~2 minutes
  2. I can connect to databases and branches, they are just subjected to the same 2 minute restriction

This issue isn't really a blocker for me because all of the commands work eventually, but it does make demoing Planetscale for my team pretty painful.

@itsjxck
Copy link

itsjxck commented Apr 27, 2023

Also having this same behaviour with pscale@0.139.0 installed via brew on Ubuntu 20.04.4 in WSL2.

First command runs as normal. Subsequent commands hang for ~2 minutes before doing anything.

@mscoutermarsh
Copy link
Member

I haven't been able to recreate this yet. Our suspicion is that this has to do with keyring access.

If someone here gets a chance, could you try running pkill gnome-keyring? Then run the pscale command again. I'm curious if that temporarily improves it.

Related issue: 99designs/keyring#112

@itsjxck
Copy link

itsjxck commented Apr 29, 2023

@mscoutermarsh I can confirm that in my instance, this worked:

gurlr on  main [✘!?] is 📦 v0.1.0 via ⬢ v16.20.0 took 4s 
➜ time pscale --help
<snip output>
pscale --help  0.01s user 0.00s system 0% cpu 2:00.11 total

gurlr on  main [✘!?] is 📦 v0.1.0 via ⬢ v16.20.0 took 2m 0s 
➜ pkill gnome-keyring

gurlr on  main [✘!?] is 📦 v0.1.0 via ⬢ v16.20.0 
➜ time pscale --help 
<snip output>
pscale --help  0.01s user 0.00s system 0% cpu 3.215 total

@mscoutermarsh
Copy link
Member

@itsjxck wow, thank you. Will keep looking into the keyring then.

@dbanck
Copy link
Author

dbanck commented May 2, 2023

Thanks for looking into this! I can confirm the same behavior with gnome-keyring.

Killing it after each pscale command "works".

@iambillmccann
Copy link

That partially solves the problem for me. It reduced the time from four minutes down to two minutes. Apparently there is something else going on too.

 ~/repositories  time pscale --version
pscale version 0.136.0 (build date: 2023-04-05T18:22:00Z commit: bd872ad)

real    4m12.467s
user    0m0.013s
sys     0m0.000s
 ~/repositories  pkill gnome-keyring
 ~/repositories  time pscale --version
pscale version 0.136.0 (build date: 2023-04-05T18:22:00Z commit: bd872ad)

real    2m10.787s
user    0m0.006s
sys     0m0.008s
 ~/repositories 

@mscoutermarsh
Copy link
Member

Great info, thank you.

@iambillmccann
Copy link

iambillmccann commented May 3, 2023

@mscoutermarsh, if there is other information that would be helpful ... let me know. Also, if the source code is available (is it open source?), I would be willing to run it in a debugger.

Um. NVM, I see the code is here, in this repo. Duh.

@mscoutermarsh
Copy link
Member

@iambillmccann That'd be incredible! No one on our team has been able to reproduce it just yet.

We believe it's likely timing out when accessing the keyring here:

func openKeyring() (keyring.Keyring, error) {

Or it may be when reading/writing it.

func readAccessTokenPath() ([]byte, error) {

@dbussink
Copy link
Collaborator

dbussink commented May 3, 2023

Related issue: 99designs/keyring#112

Fwiw, I don't think this issue is just related, but it's exactly this problem that we're hitting here. @iambillmccann You probably end up debugging that package when following the bread crumbs. But if you have any information for us, or for them that would be amazing!

@simonknittel
Copy link

simonknittel commented May 20, 2023

I'm having the same issue.
CLI version: 0.144.0
Ubuntu version: 22.04.2 (WSL2)

Running pkill gnome-keyring before each command also seems to be working for me.

If there is anything I could help you debugging let me know.

I've put an alias in my .bashrc as workaround:

alias pscale="pkill gnome-keyring && pscale"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants