Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

tier connect hangs #310

Open
prologic opened this issue Aug 5, 2023 · 10 comments
Open

tier connect hangs #310

prologic opened this issue Aug 5, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@prologic
Copy link

prologic commented Aug 5, 2023

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 prologic added the bug Something isn't working label Aug 5, 2023
@jevon
Copy link
Contributor

jevon commented Aug 5, 2023

I was no able to reproduce this.

Is it possible you have something blocking network calls?

@prologic
Copy link
Author

prologic commented Aug 5, 2023

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
Copy link
Author

prologic commented Aug 5, 2023

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
Copy link
Author

prologic commented Aug 5, 2023

But as I said the function fetchProfile()

tier/cmd/tier/connect.go

Lines 92 to 108 in 78939e2

func fetchProfile(ctx context.Context, pollURL string) (*profile.Profile, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Minute)
defer cancel()
bo := backoff.NewBackoff("keys", nopLogf, 5*time.Second)
for {
ks, err := fetchOK[*profile.Profile](ctx, "GET", pollURL, nil)
if err == nil {
if ks.Redeemed {
return ks, nil
} else {
err = errNotRedeemed
}
}
bo.BackOff(ctx, err)
}
}
is defective here as:

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

@bmizerany
Copy link
Contributor

bmizerany commented Aug 9, 2023

@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.

@prologic
Copy link
Author

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
Copy link
Author

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

@bmizerany
Copy link
Contributor

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

@prologic
Copy link
Author

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

@bmizerany
Copy link
Contributor

bmizerany commented Aug 14, 2023

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants