-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
jQuery.ajax uncaught Exception for jsonp calls to 404 error page even though response header Content-Type: text/html
is present
#5034
Comments
Content-Type: text/html
is present
Looking at the code, I might suggest some changes to the following lines: Lines 272 to 279 in 5d5ea01
At this place I think there is enough information in the One other thought - I haven't looked too much into the jQuery 2.0 version, but it might be a good idea to check what was going on there to see what was the solution there that would prevent this kind of error from being uncaught. |
This is reminiscent of #4655 |
@dmethvin , Also the other errors says that the errorHandler is NOT called, and I'm fairly sure that in this test case the error handler is called; however, the issue is that there is still an uncaught exception that will fail most default QUnit test cases that attempt. |
@codefactor Thanks for the report. There's actually no difference in converter code; converters also run in jQuery 2.x. This is a result of one of fundamental assumptions of What's different is that in jQuery 2.x In jQuery 3.0.0 we decided to simplify the logic and always use script injection, with the caveat errors can only be detected via Interestingly, we didn't cover that in the upgrade guide: https://jquery.com/upgrade-guide/3.0/. We should address that part. @dmethvin #4655 is tangential to this issue; see also the followup in #4773 (and also #4778 but that one will only apply to |
I'm fine with this for successful responses, but it seems like this should not be the case for error responses. Problem is I don't yet know the implications of that opinion. |
We'll re-evaluate this for |
Description
Upgrading from version 2 to version 3 of jQuery we see uncaught exceptions being thrown in unit test cases that cause certain unit tests to fail due to these uncaught exceptions. This causes is a backwards incompatibility to adopt version 3 we need to hack our unit test to ignore certain uncaught exceptions or otherwise detect the test environment to avoid requests to URLs that don't work in this environment. It would be good if we can fix that incompatibility since it seems easily avoidable.
Steps to Reproduce:
Run something like this:
Assume the URL goes to some place which responds with 404 status and a
Content-Type: text/html
response header and responseText with HTML content.Expected Behavior:
No uncaught exceptions should be observed.
Actual Behavior:
An uncaught exception is thrown attempting to evaluate the response text, which is not a script but HTML content.
Suggested Solution:
Do not attempt to DOMEval a 404 response during jsonp evaluation, an additional clue that this response is not a script is the content type response header. Either one should be sufficient.
Link to test case
Failure in jQuery 3.X: https://jsfiddle.net/5o94ujsL/
Same thin in jQuery 2.X: https://jsfiddle.net/m3dp2zbt/
In both cases the global error handler should not be invoked, but we see in jquery 3 that the global error handler is invoked because of the following stack trace:
The text was updated successfully, but these errors were encountered: