Skip to content

Retry-After is returned in seconds, not ms #862

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

Merged
merged 1 commit into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ Raven.prototype = {
// If Retry-After is not in Access-Control-Expose-Headers, most
// browsers will throw an exception trying to access it
retry = request.getResponseHeader('Retry-After');
retry = parseInt(retry, 10);
retry = parseInt(retry, 10) * 1000; // Retry-After is returned in seconds
} catch (e) {
/* eslint no-empty:0 */
}
Expand Down
4 changes: 2 additions & 2 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,12 +1207,12 @@ describe('globals', function() {
var mockError = new Error('401: Unauthorized');
mockError.request = {
status: 401,
getResponseHeader: sinon.stub().withArgs('Retry-After').returns('1337')
getResponseHeader: sinon.stub().withArgs('Retry-After').returns('2')
};
opts.onError(mockError);

assert.equal(Raven._backoffStart, 100); // clock is at 100ms
assert.equal(Raven._backoffDuration, 1337); // converted to int
assert.equal(Raven._backoffDuration, 2000); // converted to ms, int
});

it('should reset backoffDuration and backoffStart if onSuccess is fired (200)', function () {
Expand Down