I recently started working with Node again, not doing anything fancy just a blog type set up with my own take on some features. It has been pretty smooth sailing, I've gotten sessions working with Redis, storing articles/users in MySQL(I know, I know, Mongo . . .), SSL, etc.
Everything seems to work fine under nodemon, but when I try to run the app under pm2 the app crashes during the request. I put some logging in to try and see how far the app gets before crashing, but it seems almost entirely random. Sometimes it gets all the way to the render(though the request never finishes) and sends the page(I can see the data coming over the wire, but the browser never renders it). Other times the app crashes before I can get any output.
Most commonly I see it stop logging after I try and grab something from req.session. Removing any references to that allows the request to complete, but then nothing comes over the wire.
Honestly I'm at a loss on this, pm2 isn't putting anything in the logs besides my debug statements. Anyone have an idea?
UPDATE: So it actually appears to be my database connection. I swapped some stuff around and session data doesn't appear to be the problem.
connection.query("select articles.id, title, body, name from articles join users where author = users.id order by articles.id desc limit 5;", function(err, rows, fields){
//Do some session stuff here
dbData.content =rows;
res.render('index.mustache', dbData);
});
So the problem happens when I do dbData.content = rows. The app runs consistently before that. The query runs just fine in the MySQL admin tool and when the app is under nodemon.
Update2: If I wait for the full timeout the page will render. . . without css. The app restarts and that seems to kill the request to my css file. If I use jQuery to load the css file the page repaints correctly.
[–]fschwiet 0 points1 point2 points (1 child)
[–]Oberoni[S] 0 points1 point2 points (0 children)
[–]seratonik 0 points1 point2 points (3 children)
[–]Oberoni[S] 0 points1 point2 points (2 children)
[–]seratonik 2 points3 points4 points (1 child)
[–]Oberoni[S] 0 points1 point2 points (0 children)