NodeJS server not serving entire files?

2019-09-14 22:12发布

问题:

This is a classic "it worked last night when I went to bed!" situations...

My site is built on the MEAN stack (meanjs.org), and my page now fails to load in Chrome and IE, but seems to work fine in FireFox. It simply displays a blank white screen. I see these as the first 2 errors in the console:

socket.io.js:3032 Uncaught SyntaxError: Unexpected end of input
angular.min.js:95 Uncaught SyntaxError: missing ) after argument list

In inspecting those files, it seems they only loaded partially. I've compared them with the files on my server, and they're simply being cut off, but they're being cut off at the same point every time.

Earlier this morning, on an entirely different network (at a hotel), I was getting this error:

net::ERR_INCOMPLETE_CHUNKED_ENCODING

Unfortunately, searching on Google and SO typically shows instances of user syntax error, but I haven't touched my socket.io file or my angular.min.js file (I didn't even know where my socket.io file was until this morning).

Any help on this one?? I'm stumped.

回答1:

Short Answer: Restart NGINX - it was a caching issue.

OK, at one point, I got net::ERR_CONTENT_LENGTH_MISMATCH on my favicon. When searching this error, I found this post describing nginx issues. When looking through my nginx error logs, I found these lines:

2016/11/24 12:08:14 [crit] 31776#0: *559245 open() "/tmp/nginx_proxy/0000094496" failed (2: No su
ch file or directory) while reading upstream, client: xx.xxx.xxx.xxx, server: myserver, request: "G
ET /socket.io/socket.io.js HTTP/1.1", upstream: "http://xxx.x.x.x:xxxx/socket.io/socket.io.js", h
ost: "myhost.com", referrer: "http://myhost.com/url/path"

2016/11/24 12:08:14 [crit] 31776#0: *559248 open() "/tmp/nginx_proxy/0000094497" failed (2: No su
ch file or directory) while reading upstream, client: xx.xxx.xxx.xxx, server: myserver, request: "G
ET /lib/angular/angular.min.js HTTP/1.1", upstream: "http://xxx.x.x.x:xxxx/lib/angular/angular.mi
n.js", host: "myhost.com", referrer: "http://myhost.com/url/path"

2016/11/24 12:08:17 [crit] 31776#0: *559238 open() "/tmp/nginx_proxy/0000094498" failed (2: No su
ch file or directory) while reading upstream, client: xx.xxx.xxx.xxx, server: myserver, request: "G
ET /modules/core/client/img/brand/favicon.ico HTTP/1.1", upstream: "http://xxx.x.x.x:xxxx/modules
/core/client/img/brand/favicon.ico", host: "myhost.com", referrer: "http://myhost.com/url/path"

When I looked in /tmp I saw no nginx_proxy directory at all.

In the end, I just restarted nginx and the issue magically went away. I now reload my page without problem, and I see no more errors in the log.

Updating question with correct tags as well.