-
Notifications
You must be signed in to change notification settings - Fork 479
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
Errors not getting thrown in Cordova #66
Comments
It would be helpful to know what Cordova/Phonegap combo was used, and on what platform. If you can find out what the HTTP status code is for the value returned here: https://github.com/requirejs/text/blob/master/text.js#L288 that would help too. Also log out the URL, maybe there is something funky with the type of protocol/scheme that is uesd (like 'http:' or 'app:'). |
I am having a similar problem - test code worked in chrome, fails on Android. The problem (in my case) is that XMLHttpRequest returns status code 0 when the file is not found. The status code check in line 289 (v2.0.10) doesn't take into account this possibility: Modifying the condition to: makes things work as expected. |
Fixed and released 2.0.11 with the fix. |
I just noticed that our code started breaking after auto-updating to this minor version :( It appears that this change breaks code in PhantomJS. I suspect that more generally it breaks when using the file:/// protocol: since there is no HTTP request, there is no sensible status code it can use. For the time being I've downgraded to 2.0.10, but this should really be fixed. |
Wow, I messed that up. I confused allowing for zero for local files and the issue reported here, which is android specific for a failed file. I reverted the change and released 2.0.12. So for Android where it reports 0 for a failed XHR call, I will likely need a test case/Android version failure range, or some other check than the status code. Unfortunately I am not set up to do this sort of test easily. Will reopen to allow others to discuss and find a fix. |
Cool, thanks for the quick action! I've been using requirejs on a Cordova project without trouble, but I haven't tested what it does with failed calls. I can't promise anything, but when I have time I could look into it, if others haven't in the meanwhile. |
This is also an issue with cross-domain requests. |
Hi everyone,
I'm using the following structure in order to do something depending on whether a template file is found or not:
require ( [text!filename],
function(file) { console.log('success') },
function(err) { console.log('error') } );
This works fine on chrome but, when on a Cordova/Phonegap app, it always returns 'success', even if the file does not exist.
The text was updated successfully, but these errors were encountered: