Search code examples
javascriptangularwebstorm

Angular main js file truncated?


I have an Angular 7 application that was working fine a few minutes ago. It is still working on the local host using ng serve, but I did ng build --prod to build the production build and uploaded it to the server. When I go to it on the server it is blank and gives me an error in the console Unexpected end of input.

I looked at it and the main.21e...86.js file is being truncated and that's where it shows the error. The file is minified by the Angular build process so it's all one very long line.

Here is the output of the build:

Date: 2019-08-22T18:10:34.457Z
Hash: 60984d51912589979e3b
Time: 155732ms
chunk {0} runtime.ec2944dd8b20ec099bf3.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.21e3c2279d182c22c8a6.js (main) 1.88 MB [initial] [rendered]
chunk {2} polyfills.3bfd66addbd0d2814591.js (polyfills) 41 kB [initial] [rendered]
chunk {3} styles.1ca72067a91cb35b9ca1.css (styles) 482 kB [initial] [rendered]

Here is a direct link to the js file: https://revolutiondesign.biz/apps/portal/main.21e3c2279d182c22c8a6.js. What's weird is that I have looked at the local file as well as the one on the server and it ends with o.subscribeToArray(t))}}},[[0,0]]]); (i.e. it looks like a valid js file) but what is coming back from either the direct opening in a browser or the request viewed through dev tools ends with t.prototype.useRelativePosition=function(t){re which is obviously not valid.

Can anyone help? What is causing this file to truncate like that and more important what can I do about it? I have tried a rebuild, reload, clear cache, multiple browsers, restart the editing program I'm using (WebStorm), re-upload... Nothing seems to change this.

EDIT

Here is the actual page link: https://revolutiondesign.biz/apps/portal/


Solution

  • For anyone that comes across this, the issue ended up being related to CloudFlare caching as far as I can tell. It seems like I refreshed the page before the cache was fully updated (at least that's the best I can figure) and it ended up with only part of the file on the cache that I was referencing. When this has happened again later I was able to go into CloudFlare settings and clear all caches and it came back normally. I also now try to wait a few minutes after uploading the new files and then do an empty cache and hard reload from my browser and haven't had it happen in quite a while.