okta / okta-jwt-verifier-python

okta-jwt-verifier-python
https://github.com/okta/okta-jwt-verifier-python
Apache License 2.0
32 stars 15 forks source link

Clear cache if http client fails #45

Open anthony-ism opened 1 year ago

anthony-ism commented 1 year ago

I noticed an issue with the lib, if my http client initially failed, it would never work from that point forward until the process was restarted.

This is an issue with the "AsynceCacheControl" lib, because it is waiting for a failed request to finish and that will never happen, however this lib could easily prevent this from happening with this PR.

To reproduce what I was seeing, in a docker container I removed the default gateway (disconnected from the internet) and attempted to verify a jwt. It fails, as it should because it cannot connect to the host. However, each subsequent failure is a "Timeout" failure, which originates here (https://github.com/MasterSergius/acachecontrol/blob/master/src/acachecontrol/cache.py#L131).

This is because cache contains this request, it doesn't even attempt the http call again because its waiting for the failed one to finish.

So even after the internet is reestablished it will not move passed the timeout issue until the process is restarted.

Hope this helps, and thanks for the lib!

Thanks!