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
Currently the rate-limit handling code interprets the contents of the x-ratelimit-reset header as a number of milliseconds from the current time to wait. (see:
However, the x-ratelimit-reset value being returned by Okta FGA is a Unix timestamp rather than an offset from the current time, meaning hitting the rate limit will theoretically cause the code to hang for ~20 days. Further down it also seems to interpret it as either a number of seconds or minutes from the current time, though this property doesn't seem to be used in the delay. An example of the headers I am receiving are:
Retry on 429s, falling back to exponential backoff
Retry on 5xxs (except 501 not implemented) only if the Retry-After headers are sent - do not fall back to exponential backoff
For all others:
All 429s, and >=500 (except 501 not implemented)
Max Allowable Retries
15
Default Number of Retries
SDKs: 3
Retry Parameters
If Retry-After header is found, use it
if it is an integer, treat it as the number of seconds from now to retry, if it is <1 from now or >1800 from now (aka >30 min) - assume it is invalid and continue
if it is a date, parse it but if it is <1 from now or >1800 from now (aka >30 min) - assume it is invalid and continue
If neither header is found, use exponential backoff but we'll add some jitter, so the retry is a random number between
2^loopCount * 500ms and 2^(loopCount + 1) * 500ms
if the result of (a) is > 120s, cap it at 120s which should happen between the 8th and 9th retry
That means:
if retry-after header was returned and is valid, we’ll use it - so if it says in 4 min all good
if retry-after header was not returned, we will retry at:
500ms
1s
2s
4s
8s
16s
32s
64s
120s ← at this point is is >4min since initial call
Checklist
Description
Currently the rate-limit handling code interprets the contents of the
x-ratelimit-reset
header as a number of milliseconds from the current time to wait. (see:dotnet-sdk/src/OpenFga.Sdk/Exceptions/Parsers/RateLimitParser.cs
Line 96 in 02bbc98
Retry-After is a standard header used by APIs to indicate when the SDK can retry.
The SDK should:
X-Rate-Limit-Reset
(currently only .NET SDK supports that)Expectation
The SDK interprets the rate limit reset header as a Unix timestamp, or provides an option to do so.
Based on openfga/sdk-generator#495, it should do the following
Retry On
Max Allowable Retries
15
Default Number of Retries
SDKs: 3
Retry Parameters
If
Retry-After
header is found, use itIf neither header is found, use exponential backoff but we'll add some jitter, so the retry is a random number between
2^loopCount * 500ms and 2^(loopCount + 1) * 500ms
That means:
Reproduction
OpenFGA SDK version
0.5.0
OpenFGA version
N/A
SDK Configuration
ApiUrl, StoreId, AuthorizationModelId and Credentials are provided. No other configuration.
Logs
No response
References
The header is interpreted as a number of milliseconds from the current time here:
dotnet-sdk/src/OpenFga.Sdk/Exceptions/Parsers/RateLimitParser.cs
Line 96 in 02bbc98
And the delay happens here:
dotnet-sdk/src/OpenFga.Sdk/ApiClient/ApiClient.cs
Line 129 in 02bbc98
The text was updated successfully, but these errors were encountered: