gadicc / meteor-headers

Access HTTP headers on both server and client. Client IP with proxy support.
https://atmospherejs.com/gadicohen/headers
GNU Lesser General Public License v3.0
61 stars 21 forks source link

Offline issue: Uncaught SyntaxError: Unexpected token < #37

Open gadicc opened 9 years ago

gadicc commented 9 years ago

Originally reported by @almogdesign in https://github.com/gadicc/meteor-messageformat/issues/91:

If my app is in offline mode, not internet connection and it loads everything from app cache and groundDB I'm getting the following error message

Resource interpreted as Script but transferred with MIME type text/html: "https://xstaging.goplatfarm.com/headersHelper.js?token=1425899998591.4875". headersHelper.js?token=1425899998591.4875:1 Uncaught SyntaxError: Unexpected token < 4c603d60d86a8256c2320771323525a21c7300dd.js:32

I'm not 100% sure whats casing it

gadicc commented 9 years ago

Yeah, this does seem weird.

I can confirm that headersHelper.js is being transferred with the correct mime-type, both in the code and as being received in Chrome. And also that the syntax is all correct.

So it's quite weird that this is only in offline mode. It seems maybe like a browser cache issue. Do you get the same with any other browser? Are you at all able to see the contents of headersHelper.js from the cache? And/or 4c603d60d86a8256c2320771323525a21c7300dd.js line 32? Not sure what that is :(

isAlmogK commented 9 years ago

@gadicc right now only tested it on Chrome, which is the only browser we're supporting at the moment

gadicc commented 9 years ago

Ok, I should also quote from your more recent message:

When offline mode I'm getting the following error message not sure if this is affecting anything.

Resource interpreted as Script but transferred with MIME type text/html: "https://xstaging.goplatfarm.com/headersHelper.js?token=1425982012935.465".

Where we get the first warning but not the 2nd error. In general it's a harmless error but I do prefer to avoid these things if I can, just need to work out where it's coming from. Self note, think about how this can/should be added to the offline manifest.

tdesc commented 9 years ago

I also getting this error on iOS Simulator with cordova build Uncaught Error: SyntaxError: Unexpected token '<':1:http://meteor.local/headersHelper.js?token=1444160435205.5044

jamesgibson14 commented 8 years ago

I get this with meteor run android-device as well.

MartinFournier commented 8 years ago

@gadicc I've been hitting a similar issue with messageformat (with the /msgfmt/locale/all file), I think it's because meteor seems to lack 404 status code errors by default. In Cordova, the file is not found at meteor.local/ (somehow, not sure why yet).

Meteor returns the error page (with a status code of 200, and text/html instead of application/javascript). It then try to embed it under a script tag which causes the syntax error.