Skip to content

Catch XHR errors - #222

Merged
LinusU merged 2 commits into
evanw:masterfrom
dirkluijk:xhr-error-catch
Aug 20, 2018
Merged

LinusU merged 2 commits into
evanw:masterfrom
dirkluijk:xhr-error-catch

Conversation

@dirkluijk

@dirkluijk dirkluijk commented Aug 17, 2018

Copy link
Copy Markdown
Contributor

When the XHR request throws an error (e.g. in case of CORS issues), it is now catched properly. Needed to fix weird Karma/Jasmine issues in Angular CLI projects.

Closes angular/angular-cli#7296.

Comment thread source-map-support.js Outdated
var xhr = new XMLHttpRequest();
xhr.open('GET', path, false);
xhr.send(null);
var contents = null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't redeclare contents here.

Comment thread source-map-support.js Outdated
try {
// Use SJAX if we are in the browser
var xhr = new XMLHttpRequest();
xhr.open('GET', path, false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment like
// Note: synchronous XHR
It's very weird so a comment would alert readers that it is intended.

or you could use /** async */ false in the call.

@dirkluijk

Copy link
Copy Markdown
Contributor Author

I did not change any of the original code in this PR, just added the try/catch. But of course I can have a look at it.

@dirkluijk

Copy link
Copy Markdown
Contributor Author

@johnjbarton fixed.

@LinusU

LinusU commented Aug 20, 2018

Copy link
Copy Markdown
Collaborator

Looks great! Thanks, added a commit to refactor the try/catch, will merge when CI is green 👍

@LinusU
LinusU merged commit d665b19 into evanw:master Aug 20, 2018
@dirkluijk

Copy link
Copy Markdown
Contributor Author

Thanks! 👍

@duydnguyen07

Copy link
Copy Markdown

@LinusU When are you planning to make a release that will contain this commit?

@dirkluijk
dirkluijk deleted the xhr-error-catch branch August 20, 2018 11:34
@LinusU

LinusU commented Aug 20, 2018

Copy link
Copy Markdown
Collaborator

Thx ❤️ released as 0.5.9 🚀

edit: @duydnguyen07 yes ☺️ took a bit longer since I had a problem with the build script 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression wrong error message during tests if runtime error occurs after constructor

4 participants