Diagnose Meteor (Node.js) service hangs - javascript

I have a Meteor (Node.js) app in production that keeps hanging unexplainably in production. I have put a number of log statements in the code, so I can see that it hangs on a certain method.
My question is if there are any other tools other that the console log that might give me insight into the resource consumption of a Node.js app. Something that might tell me why the app is hanging.
The method on which the server hangs is a method that uses a geocluster and geolib NPM. It usually happens after a method where the Facebook-node-SDK is called.
I am thinking that there might be memory consumption from the calls to the geo npm, or open http connections from the facebook-node-sdk?
Please let me know if there is more information that I can provide. Any help would be appreciated.

You could try node-inspector and pass environment run vars to meteor via NODE_OPTIONS='--debug-brk' meteor run and try your luck there.
(2017 update: there was an answer here referencing Kadira (kadira.io) however this service is no more.. sad).
You may also try the built-in NodeJS devtools available since 6.3. If you read the node-inspector github repo, you can see a blog post referenced there to get started:
https://medium.com/#paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.pmqejrn8q

You can try Webstorm, version 9 has meteor support, debugging included.

Related

Error: GET http://localhost:4200/assets/vendor.js net::ERR_INVALID_CHUNKED_ENCODING, on Ember.js server

I am just getting started with Ember.js at v2.9.0, followed the tutorial on their page https://guides.emberjs.com/v2.9.0/tutorial/ember-cli/, all good, save for one detail: Whenever I tried to refresh or load the development web app on Chrome browser after executing ember server on the cmd, the app would not load in browser and provide the following error most of the time (there were other errors as well but seem to be related to this one):
GET http://localhost:4200/assets/vendor.js net::ERR_INVALID_CHUNKED_ENCODING
, and one of the related errors is:
Uncaught ReferenceError: define is not defined
at application.js:1
I have searched for this specific error but without luck, I tried some fix hints found, such as clearing some persistent data with the netsh command, doing an npm cache clean bower cache clean, deleting the node_modules and the bower_components folders and reinstalling dependencies; also ensuring that there was no weird proxy configuration in my LAN settings, etc.
I have encountered this error while following the tutorial, and it would kind of be bypassed by refreshing the browser a few times until the app displayed. That was before, but now the refresh does not work when working on an existing application.
I am on:
Windows 10
ember-cli v.2.9.1
node.js LTS v.6.9.1
I need to get going with this rather soon, so any hint to resolve this issue is appreaciated. Thanks!
Might be a conflicting process running... Are you working over a VPN? If so, take a look at https://superuser.com/questions/893908/err-invalid-chunked-encoding-from-chrome

Running meteor app on Windows from MacOS

I got a Meteor project from a friend who develops on MacOS.
When trying to run it, I get:
This project uses METEOR#1.0.2.1, which isn't available on Windows. To
work with this app on all supported platforms, use meteor update
--release METEOR#1.2.1 to pin this app to the newest Windows-compatible release.
When running it, I get:
While checking for cfs:gridfs#0.0.27: no compatible binary file
found...
Then, when I try to override (use run instead of update), without actually updating, it starts proxy and Mongo, but then breaks at, but skips the first error
While building package npm-container: error: No plugin known to handle
file '../../packages.json'. If you want this file to be a static
asset, use addAssets instead of addFiles; eg,
api.addAssets('../../packages.json', 'client').
I read that this error is fixed by updating meteorhacks, but when I try to, I get the Meteor version conflicts (see very first error) and I have no idea how to break out of the loop.
Can someone shine some light on how to fix any of these error?

Dillinger stuck at "prepping all the things" when running locally

Update: I have checked the console for error, it catches
Uncaught ReferenceError: require is not defined
According to some online posts, it is probably due to the use of require on the browser side. require is meant to be a syntax for Node, which is used on the server side. But the use of [Browserify][browserify.org/] made this possible.
Im not sure how this works but hope someone may give me some advice.
I was trying to run Dillinger on my own Macbook Pro (13-inch)
I followed the instructions on the README.md but when running locally it shows this.
PS. As suggested by post here, I modified the package.json that the dependency installation can proceed.
Dropbox config not found at /Users/[name]/dev/dillinger/plugins/dropbox/dropbox-config.json. Plugin disabled.
Github config not found at /Users/[name]/dev/dillinger/plugins/github/github-config.json. Plugin disabled.
Google Drive config not found at /Users/[name]/dev/dillinger/plugins/googledrive/googledrive-config.json. Plugin disabled.
OneDrive config not found at /Users/[name]/dev/dillinger/plugins/onedrive/onedrive-config.json. Plugin disabled.
express deprecated app.configure: Check app.get('env') in an if
statement app.js:19:5
connect deprecated multipart: use parser (multiparty, busboy,
formidable) npm module instead
node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:56:20
connect deprecated limit: Restrict request size at location of read
node_modules/express/node_modules/connect/lib/middleware/multipart.js:86:15
connect deprecated methodOverride: use method-override npm module
instead app.js:27:19
express deprecated app.configure: Check app.get('env') in an if
statement app.js:56:5
Express server listening on port 8080
http://localhost:8080
When I send a request, it shows this :
Evernote not implemented yet.
GET / 200 34.139 ms - -
GET /css/app.css 304 4.351 ms - -
Then when I tried to open Dillinger at localhost, it is stuck at "Prepping all the things..."
Anyone has any idea why this is so? I am new to Javascript and Node.JS so forgive me if the question looks dumb.
Many thanks in advance!

How to debug Node.js with Socket.io

I'm using the Google Chrome Developer Tools plugin for Eclipse to debug my Node.js server. This server uses Socket.io for the websocket connection between my web client and the server. The problem comes when I set a breakpoint in my server and start stepping through the code. The client soon decides the server isn't there anymore because there's no longer a heartbeat or any communication, so it disconnects. Meanwhile, as I'm stepping through, my code tries to do something with the socket and then it dies since the socket is now shutdown. It makes it a bit tricky trying to debug like this.
So the question is, how can I debug a server like this with an open websocket connection and not close the connection? I don't know that there's a good solution, but I thought I'd put it out there and see if anyone has a genius idea.
Even if it sounds a littly nasty and stone-aged, but in this cases (actually debugging a client->server environment) I regulary use standard outputs on the server-side, just like console.log() and console.debug.
If you need to debug your client-side script, you could do just the same, if you don't want to lose the server connection. I actually don't see any other way around it beside you re-configure socket.IO's heartbeat timeouts fundamentally higher.
After doing more research I discovered a couple different projects that looked hopeful, namely 'node-inspector' and 'node-codein'. However, node-inspector doesn't work with the latest versions of node, and node-codein has a lot of bugs. Also, neither is really maintained and they both only work with Chrome. So, I wrote my own solution, called Node Monkey, which is really simple to use and it works with Firefox or Chrome. It simply captures things logged to the console in your Node app and redirects that output to the browser console. You can install it by running:
npm install node-monkey
I know this is ages later, but another option I found that ended up being perfect for a quick socket.io sanity check is socket-io-tester.
I mention it here since this answer was the first result on google and it took me a little more digging to find the tool.
for this you can follow official documentation of socket.io
https://socket.io/docs/v3/logging-and-debugging/index.html
In my case, I did this in my package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "DEBUG=engine,socket.io* nodemon src/server.js"},
I hope it will help you or feel free to ask me in case you have any doubt

Installing/setting up Socket.IO on my server

Ok so I have read through the Socket.IO docs and I am still a little unsure of a couple of points:
The documentation says...
To run the demo, execute the following:
git clone git://github.com/LearnBoost/Socket.IO-node.git socket.io
cd socket.io/example/
sudo node server.js
Now I don't know what this means at all! I think it may be command line interface. I of course have access to this on my localhost, but my online hosting package is a shared LAMP setup. Meaning I don't have access to the root command line (i think).
How do I actually setup socket.IO, is it impossible on my shared server package?
Appreciate any help...
W.
If you aren't familiar with node.js or with basic command line usage then I would suggest that you use a hosted WebSockets solution like pusherapp. Trying to learn WebSockets, and Node.js, and the Linux command line all at once is going to lead to a lot of frustration. Take a look a pusherapp's quick start guide, it's very easy to get started. You can have 5 simultaneous connections with a single application for free (I'm not affiliated with pusherapp).
Updated (with inline answers to questions):
If you are going to go the direction of running a Socket.IO application:
You don't technically need git since you can download node.js and Socket.IO from their respective download links on github.
You don't actually need a LAMP server to use Socket.IO. By default Socket.IO functions as a simple webserver in addition to a WebSockets server. If you want server side scripting then you might want Apache with mod_php, mod_python, etc.
You don't technically need a dedicated server or even root access. You do need a system where you can have long running process. And if you want the service to start automatically when the system is rebooted, you probably want to add a startup file to /etc/init.d, /etc/rc.d which will require root access. Both node.js and Socket.IO can be installed and run from a normal home directory. If you want to run Socket.IO on a standard port like 80 or 443 then you will need to run it with root privilege.
Node.JS scales quite well so Socket.IO will probably scale pretty well too.
It's not a simple matter to get everything setup and working, but if your goal is a free solution for web serving+WebSockets then Socket.IO is probably is good route to at least explore if you are brave.
First you'll have to determine if your host supports SSH. Sometimes they don't by default on shared hosting, but if you ask they can turn it on. If it does you'll use some sort of SSH client to connect to it. Putty for windows is the most common. Then you'll use git, which is a source control program. Which you'll probably have to install on your host, which may or may not be allowed. If you can, this can be accomplished a number of ways, you'll want to read the git documentation, it will depend largely on what linux distribution you're running. CD is change directory, basic command line stuff. sudo on the last line is telling the system to run the command as root, which it will ask you the password for, which you may not have access to on your host. Sounds like you're gonna have an uphill battle on shared hosting. You may want to opt for a VPS instead.
If your shared host is a LAMP system with no command line access you're not going to get very far with Socket.IO. The instructions you posted assume you have command line access and that you've installed the node.js runtime on your system.
If you really want to try this I recommend you get a VPS of your own (I use prgmr.com) to test it out. For what it's worth I found the Socket.IO platform pretty nice to use once I got it up and running.

Categories