You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @mattbdean, just want to start by saying I really enjoy the library you've written here and it's saved me a lot of work for my own project, a Reddit source connector for Kafka. Thanks man!
So, the issue--like the title mentions, I believe there's a race condition with token refresh. It may or may not be specific to streams, but that's the only place I've noticed it so far.
In the RedditClient.request(...) method, a check for token refresh is made based on AuthManager.needsRenewing(); if and only if that method returns true, the token is refreshed. However, since the needsRenewing method only returns whether or not the token has already expired and not whether it's likely to expire soon, it's possible that in between that check and the actual request to Reddit, the token expires.
I think one easy fix could be to alter the needsRenewing method to return whether a given percentage of the token's lifetime has elapsed; this could be anything from 50% to 99%, depending on how expensive it is to fetch a new token and how much time is expected to elapse between calls to that method and requests that then use the possibly-expired token. If you agree, I'd be happy to open a PR up to add this--let me know.
The text was updated successfully, but these errors were encountered:
It should also be noted that a quick workaround I've discovered is to silently swallow ApiExceptions whose status code is 401 and immediately retry, so this isn't a super urgent or catastrophic problem. However, it still seems worth addressing in the JRAW library itself to avoid requiring this workaround if possible.
Hi @mattbdean, just want to start by saying I really enjoy the library you've written here and it's saved me a lot of work for my own project, a Reddit source connector for Kafka. Thanks man!
So, the issue--like the title mentions, I believe there's a race condition with token refresh. It may or may not be specific to streams, but that's the only place I've noticed it so far.
In the RedditClient.request(...) method, a check for token refresh is made based on AuthManager.needsRenewing(); if and only if that method returns true, the token is refreshed. However, since the
needsRenewing
method only returns whether or not the token has already expired and not whether it's likely to expire soon, it's possible that in between that check and the actual request to Reddit, the token expires.I think one easy fix could be to alter the
needsRenewing
method to return whether a given percentage of the token's lifetime has elapsed; this could be anything from 50% to 99%, depending on how expensive it is to fetch a new token and how much time is expected to elapse between calls to that method and requests that then use the possibly-expired token. If you agree, I'd be happy to open a PR up to add this--let me know.The text was updated successfully, but these errors were encountered: