You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I try to load a JSON file and I have a loading error (for example "No Access-Control-Allow-Origin header is present") the xhr status is 0 and is considered as a success. I don't know if this is correct, but supposing it is, the result of the get request is an empty string that cannot be parsed:
Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at Object._onSuccess (playcanvas-stable.dbg.js:20204)
at Object._onReadyStateChange (playcanvas-stable.dbg.js:20174)
at Object. (playcanvas-stable.dbg.js:20138)
So a simple patch would be to check for a not empty string before parsing, but I'm not sure if it's not better to understand why the xhr status zero is considered a successful request.
I had also an issue when the network was off. The get method doesn't return an error, but a successful empty result.
The text was updated successfully, but these errors were encountered:
Also, I would probably add a try catch around the JSON.parse and notify the exception as an error, so that it can be better handled by the application.
engine/src/net/http.js
Line 372 in 18bdc36
If I try to load a JSON file and I have a loading error (for example "No Access-Control-Allow-Origin header is present") the xhr status is 0 and is considered as a success. I don't know if this is correct, but supposing it is, the result of the get request is an empty string that cannot be parsed:
So a simple patch would be to check for a not empty string before parsing, but I'm not sure if it's not better to understand why the xhr status zero is considered a successful request.
I had also an issue when the network was off. The get method doesn't return an error, but a successful empty result.
The text was updated successfully, but these errors were encountered: