Please specify what version of the library you are using: [1.3.7] but it exists in 1.3.10 and 2.0.3 codebase
Please specify what version(s) of SharePoint you are targeting: [SPO]
From what I could gather on the Net, the "Retry-After" value is specified in seconds, but the pnp code uses this value directly in the setTimeout method (milliseconds).
On 429 throttling the "Retry-After" value is incorrectly used and the 7 retries are immediately executed without the expected delay.
sphttpclient.ts:
Line 88:
if (response.headers.has("Retry-After")) {
// if we have gotten a header, use that value as the delay value
delay = parseInt(response.headers.get("Retry-After"), 10);
}
Line 105:
// Set our retry timeout for {delay} milliseconds.
setTimeout(getCtxCallback(this, retry, ctx), delay);
I used Fiddler to set the Response Statuscode and "Retry-After" Header to simulate throttling. Only after setting values above 1000 the delay was noticable.
Fiddler Script:
static function OnBeforeResponse(oSession: Session) {
// SharePoint Throtteling Test
if (oSession.url.indexOf("[mytenant].sharepoint.com") > -1
&& oSession.url.indexOf("/_api/web/getList") > -1
&& oSession.url.indexOf("GetClientSideComponents") === -1
) {
oSession.responseCode = 429;
oSession.ResponseHeaders["Retry-After"] = "3000";
}
}
Thank you!
Thanks, the PR fixing this is submitted. Retry-After is actually contains not in milliseconds but seconds. Please expect the fix being merged and published no sooner than April when @patrick-rodgers is back to business from family leave.
I think the values is always 120 seconds. Microsoft say that this is the default but I'm not sure if it varies at all.
@semopz,
Even if it's currently "hardcoded" as 120 seconds on MS end (which I'm not sure about but it can be a true statement) it can be easily changed anytime later, so better rely on a value which is returned. Theoretically, it can be dynamic with a progression based on other potential requests during the throttling interval.
Thanks for reporting this and the quick fix!