{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/8063","repository_url":"https://api.github.com/repos/meteor/meteor","labels_url":"https://api.github.com/repos/meteor/meteor/issues/8063/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/8063/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/8063/events","html_url":"https://github.com/meteor/meteor/issues/8063","id":189841485,"number":8063,"title":"Cordova: Hot code push failing due to main javascript file not found","user":{"login":"matdurand","id":1435391,"avatar_url":"https://avatars.githubusercontent.com/u/1435391?v=3","gravatar_id":"","url":"https://api.github.com/users/matdurand","html_url":"https://github.com/matdurand","followers_url":"https://api.github.com/users/matdurand/followers","following_url":"https://api.github.com/users/matdurand/following{/other_user}","gists_url":"https://api.github.com/users/matdurand/gists{/gist_id}","starred_url":"https://api.github.com/users/matdurand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matdurand/subscriptions","organizations_url":"https://api.github.com/users/matdurand/orgs","repos_url":"https://api.github.com/users/matdurand/repos","events_url":"https://api.github.com/users/matdurand/events{/privacy}","received_events_url":"https://api.github.com/users/matdurand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-16T20:54:15Z","updated_at":"2016-11-23T13:20:58Z","closed_at":null,"body":"Hi. Using meteor 1.4.1.2 on Galaxy, we have intermittent errors with the hot code push on mobile devices, both on Android and iOS. The main symptom is the hot code push reverting after the webapp timeout expires and the new version is being blacklisted. This happens because the minified JS file from my meteor build is not found, so I get the following error\r\n\r\n`11-16 10:55:06.177 19002 19002 I chromium: [INFO:CONSOLE(1)] \"Uncaught SyntaxError: Unexpected token <\", source: http://`\r\n\r\nThe reason we get this error is because the requested file http://localhost:12648/4c01dfeef82fca6ece82954ec616be43d34cfba3.js is not found, so the WebAppLocalServer returns index.html as a fallback. The first character of index.html is <.\r\n\r\nThis is just a guess, but here is the sequence of events I think is happening when the error happens:\r\n1. We have an app that was version 1 and received a hot code push to version 2 in the past, so it's now running version 2.\r\n2. A hot code push (version 3) becomes available and is downloaded on the device\r\n3. The meteor reload package triggers a window reload to engage the new version\r\n4. A the same time\r\n* The onReset callback is called\r\n* The index.html is requested from the webview\r\n5. The index.html from version 2 is return. This version reference skkj4h23kj.js\r\n6. The onReset callback completes and the new AssetBundle is now version 3\r\n7. The webview request skkj4h23kj.js, but it's not found because it's in version 2, and index.html is return\r\n8. We get the error above\r\n9. After 20 sec of timeout, the version is blacklisted\r\n\r\nMy guess is that there is a concurrency issue between step 4a and 4b. When 4b happens first, all is good. When 4a happens first, we get the error. I may be wrong but I'm guessing that the onReset is triggered, but the webview doesn't block and proceed in requesting the url and loading the html. \r\n\r\nI tried with both the default android webview and crosswalk, and got the same result. The only time this doesn't happen is for the first hot code push after a fresh app install, but in this particular case,  the hot code push also fails because the old minified JS is loaded (and found since it's part of the parent AssetBundle). The new code is download on the device, but not serve, and the old code runs again. Then the next time the app starts, the new bundle is loaded correctly.\r\n\r\nTo reproduce the issue, start the project in Android Studio, and add a breakpoint on the first line of the onReset callback in WebAppLocalServer. I also added logs to display when the index.html file is returned. With the breakpoint in place, the code will break but you'll see that the index.html file is requested anyway before the AssetBundle are switched in onReset.\r\n\r\nWe had a similar behavior on iOS, but I haven't debug the issue in XCode."},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/262510784","html_url":"https://github.com/meteor/meteor/issues/8063#issuecomment-262510784","issue_url":"https://api.github.com/repos/meteor/meteor/issues/8063","id":262510784,"user":{"login":"matdurand","id":1435391,"avatar_url":"https://avatars.githubusercontent.com/u/1435391?v=3","gravatar_id":"","url":"https://api.github.com/users/matdurand","html_url":"https://github.com/matdurand","followers_url":"https://api.github.com/users/matdurand/followers","following_url":"https://api.github.com/users/matdurand/following{/other_user}","gists_url":"https://api.github.com/users/matdurand/gists{/gist_id}","starred_url":"https://api.github.com/users/matdurand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matdurand/subscriptions","organizations_url":"https://api.github.com/users/matdurand/orgs","repos_url":"https://api.github.com/users/matdurand/repos","events_url":"https://api.github.com/users/matdurand/events{/privacy}","received_events_url":"https://api.github.com/users/matdurand/received_events","type":"User","site_admin":false},"created_at":"2016-11-23T13:20:58Z","updated_at":"2016-11-23T13:20:58Z","body":"I'm testing a potential fix in the coming days and if it works, I will create a PR. Thanks"}}
{"actor":{"display_login":"matdurand"}}