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

Fail faster in checkTokens #17

Closed
wants to merge 2 commits into from

Conversation

jonchurch
Copy link
Contributor

Currently the code to check tokens will return false if any of the tokens we detect fail the network request.

But we are still doing sequential network calls to check that.

This PR goes full fail fast via Promise.all and returns false if we reject

Is it faster? For most people, prolly not ¯\_(ツ)_/¯ but if a user has several tokens (like I do) but only the last of 10 is bad, it should give us a faster result.

@jonchurch jonchurch force-pushed the jonchurch/pat-check-perf branch from 679b7cf to fab7a3a Compare April 22, 2024 14:20
@jonchurch
Copy link
Contributor Author

jonchurch commented Apr 22, 2024

Edit: blegh, I haven't been able to find a way to parse the token expiry. I thought I'd done this in the past, the same way you can with a JWT, but Im not finding satisfaction this time.

I stand by this change, but interestingly we may also be able to parse the token to check its expiry, so we can fail even faster w/o a network request.

We'd still want to verify via network, but if we can fail even faster on good confidence the network request won't work bc token expiration, then that's awesome.

}

})
))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, missing ; 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed manually

@jonchurch
Copy link
Contributor Author

jonchurch commented Apr 25, 2024

Requested changes have been made!

The token parsing to check expiry locally isn't possible rn from what I have seen.

@jonchurch jonchurch requested a review from jcreamer898 April 25, 2024 19:28
@jonchurch
Copy link
Contributor Author

underlying file was deleted, logic is largely the same but closing since I don't plan to update this PR

@jonchurch jonchurch closed this Sep 13, 2024
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

Successfully merging this pull request may close these issues.

2 participants