tier icon indicating copy to clipboard operation
tier copied to clipboard

tier connect hangs

Open prologic opened this issue 2 years ago • 10 comments

What is the issue?

Running tier connect just hangs on the terminal without completing.

$ tier -v connect
tierDEBUG: background: inBackground=false
tierDEBUG: tier: profile not found
Tier connect instructions:

1. Take a mental note of the following code:

	...

2. Follow this link and verify the above code:

	...

3. Return here and continue using Tier.

The followed url to stripe appears to be successful, following the prompt, stripe says "successful you can close this window", etc.

Steps to reproduce

  1. Run tier connect
  2. Follow the instructions
  3. Wait and wait and wait and wait... I give up :)

Are there any recent changes that introduced the issue?

No response

OS

macOS

OS version

13.2.1 (22D68)

Tier version

Whatever go install ...@latest installed

prologic avatar Aug 05 '23 03:08 prologic

I was no able to reproduce this.

Is it possible you have something blocking network calls?

jevon avatar Aug 05 '23 10:08 jevon

I'lll try and debug the code and find out. The way the code is written though, I think does result in an infinite loop, because the context is never used inside the loop or checked for.

prologic avatar Aug 05 '23 10:08 prologic

Repros pretty quickly and easily here, no signs of any network calls being blocked.

Am I doing something wrong? I'm just running:

tier connect

And following the insturctions.

Screenshot 2023-08-05 at 20 42 39

prologic avatar Aug 05 '23 10:08 prologic

But as I said the function fetchProfile() https://github.com/tierrun/tier/blob/78939e21ab51293b23e7f182881a76d3f1f489e9/cmd/tier/connect.go#L92-L108 is defective here as:

  • The loop never ends if the error condition is constant
  • The timeout context is never checked for in the loop

prologic avatar Aug 05 '23 10:08 prologic

@prologic,

What is the output of tier whoami?

Do you have any STRIPE_ or TIER_ envs set? If so, please unset them and try again.

Do you have a tier.state file present? If so, try again in a fresh directory or remove the tier.state file.

If none of the above apply, please try rm -rf ~/.config/tier/ and try again.

bmizerany avatar Aug 09 '23 20:08 bmizerany

What is the output of tier whoami?

$ tier whoami
tier: There was an error looking up your Stripe API Key: profile not found
tier: Please run `tier connect` to connect your Stripe account

Do you have any STRIPE_ or TIER_ envs set? If so, please unset them and try again.

$ env | grep -i -E '(stripe|tier)' | tee | wc -l
0

$ ls -lah .state ls: cannot access '.state': No such file or directory


> Do you have a `tier.state` file present? If so, try again in a fresh directory or remove the tier.state file.
> 
> If none of the above apply, please try `rm -rf ~/.config/tier/` and try again.

I did have a `~/.config/tier` which I deleted and the same result. Hangs.

prologic avatar Aug 10 '23 09:08 prologic

I even turned off my network-wide adblocker. Same results. Just hagns.

prologic avatar Aug 10 '23 09:08 prologic

@prologic Using the stripe CLI, Are you able to successfully complete stripe login using the same account?

bmizerany avatar Aug 10 '23 20:08 bmizerany

Looks like using the stripe CLI also fails with the same message :/

$ stripe login
Your pairing code is: xxx-xxx
This pairing code verifies your authentication with Stripe.
Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?t=xxx (^C to quit)
⡿ Waiting for confirmation...unexpected http status code: 400 {"error":{"message":"The livemode of the authorization key you provided does not match that of the key provided in the Stripe-Account header.","message_code":"stripe_account_livemode_mismatch"}}

I followed the instructions here

prologic avatar Aug 11 '23 23:08 prologic

@prologic This seems like a stripe specific thing. The Stripe Discord is a wonderful and fast way to get fast answers about things like API keys https://discord.com/invite/stripe. They are very responsive and have more insight into things like this. Please let me know if that doesn't turn out to be helpful.

bmizerany avatar Aug 14 '23 04:08 bmizerany