4

I am running into trouble between two angular-fullstack apps deployed on AWS via same setup and configuration.

It seems that socket.io-client/socket.io.js isn't served properly on one of them despite having same settings.

Seems like it's getting an error 400 (bad request) when trying to get socket.io.js and in turn, it's getting an "io not defined".

I've narrowed it down to this piece of code:

var socketio = require('socket.io')(server, {
  serveClient: (config.env === 'production') ? false : true,
  path: '/socket.io-client'
});

Seems like if I set serveClient to always be true, it will work because it's always serving to the client.

If this is the case, why do so many resources online set serveClient to false for production? It works for one app but not the other.

EDIT: just deployed on AWS with serveClient: true. Doesn't work. But apparently it works on my local.

EDIT 2: did an npm install for the working app, now it's broken so maybe something is broken with packages.

EDIT 3: did a test on NODE_ENV=production after a grunt build:dist and same issue so it should be issue with one of the packages.

PGT
  • 1,468
  • 20
  • 34
  • Surely no differences in the AWS configs? I would try to run the working app on the machine of the other app to see if there is a problem with the code or the machine config. (Virtual Server I guess...) – Gábor Imre Jun 09 '15 at 08:58
  • It's on the same machine, everything is the same since I scaffolded using yeoman and only added content. The only thing I can think of is that maybe I screwed up nginx somehow, but it's pretty much just a copy of the first app as well. I took a look at the front end and it says "io is not defined" and socket.io.js is getting an error 400 – PGT Jun 09 '15 at 14:37

1 Answers1

4

Turns out angular-fullstack's built in grunt file will grab all dependencies in bower.json (via wiredep), which includes google-code-prettify/bin/prettify.min.js since I've installed it.

The minification process is somehow incompatible with the already minified prettify.min.js (never actually had this issue before with other minified files).

So I had to include a regex in the wiredep.target.exclude property to exclude google-code-prettyify/**/.js files and manually include the non-minified /src/prettify.js file.

I had a feeling the google-code-prettify package was causing problems because I remember JSHint complaining about it before.

Hopefully this brings awareness that npm packages can be broken in some intermittent way.

PGT
  • 1,468
  • 20
  • 34
  • I have the same problem but unclear about your solution. Do you kind sharing some code? – Mika Jan 25 '17 at 16:02
  • Sorry it's been 2 years and I completely forgot what this was even about. From what I wrote, it seems like I just excluded any automation done on the `google-code-prettify/bin/prettify.min.js` file, and then included it somewhere else as-is. – PGT Jan 27 '17 at 00:24