-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] http XHR request differences in error handling between our code an MDN example #8879
Comments
Hi @pmario HTTP result codes in the range 300-399 are used for various kinds of redirects. XMLHttpRequest automatically follows any redirects silently, and doesn't expose the redirects to JS code. So, while it is technically true that result codes in this range should be treated as success, they are never visible to JS code using XMLHttpRequest |
OK -- I agree with the 300 codes. -- But what's with It shows an error text, but with not all too much info. I know, that the test-case widget is no debugger, but may be we should return eg: "Use browser debug tools F12 to get more info" or something similar, if we encounter status=0 |
Hi @pmario I am not sure I understand. From your description, we see status = 0 when access is prevented by CORS. But the MDN code counts status = 0 as success. |
You are right. That's strange. With further digging at: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/status In the second quoted paragraph it says this:
So status 0 seems to be a "general -- something (not specified) is wrong" status. There no more info at: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors Not sure, what to do yet. |
Describe the bug
At http.js
request.onreadystatechange
we use:TiddlyWiki5/core/modules/utils/dom/http.js
Line 303 in f8a8f00
MDN Example shows:
Expected behavior
We should probably also use
if (status === 0 || (status >= 200 && status < 400)) {
I am pretty sure we should use
status === 0
I am not so sure about
< 400
... This may cause backwards compatibility problemsTo Reproduce
Test this code:
It has XHR request
status === 0
The browser network tab shows a 201, but FF creates NS_ERROR_UNEXPECTED
Screenshots
TiddlyWiki Configuration
TW 5.3.6
Additional context
Related to Talk: https://talk.tiddlywiki.org/t/how-to-use-tm-http-request-to-fetch-data-from-sites-into-tiddlywiki/11550/6?u=pmario
The text was updated successfully, but these errors were encountered: