Skip to content
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

Fix XHRRequest ErrorInfo bug #793

Merged
merged 3 commits into from
Sep 22, 2021
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 browser/lib/transport/xhrrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ var XHRRequest = (function() {
return;
}

var err = responseBody.error && ErrorInfo.fromValues(responseBody.error);
var err = headers['x-ably-errorcode'] && responseBody.error && ErrorInfo.fromValues(responseBody.error);
if(!err) {
err = new ErrorInfo('Error response received from server: ' + statusCode + ' body was: ' + Utils.inspect(responseBody), null, statusCode);
}
Expand Down
11 changes: 11 additions & 0 deletions spec/realtime/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,17 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
)
); /* expectFailed: */

/* 403 should cause connection to fail even with an external error response */
it(
'authUrl_403_custom_error',
authCallback_failures(
{
authUrl: echoServer + '/?status=403&type=json&body=' + encodeURIComponent(JSON.stringify({error: {some_custom: "error"}}))
},
true
)
);

/* auth endpoints don't envelope, so this won't work with jsonp */
if (helper.bestTransport !== 'jsonp') {
it('authUrl_403_previously_active', function (done) {
Expand Down