News for hackers. Stuff that matters.
Re:Hard-won lessons: Five years with Node.js by thesmallestcat on Wednesday April 19, 2017 @10:17PM (#14153445)
Can you elaborate on the "major pain in the butt to monitor and keep Node.js running production-like" What sorts of issues did you face? Certainly .NET and Java have more tooling, but I haven't noticed a difference between keeping a Node process up as opposed to a Python one. Hard to compare to stateless PHP.
Re:Hard-won lessons: Five years with Node.js by stickfigure on Thursday April 20, 2017 @01:35AM (#14154228)
The default behavior for Node when there is an uncaught error is to crash the process, killing all requests in flight. Even if you go out of your way to stop this default behavior, errors still likely leave the process in an inconsistent state. Node can't just unwind a few stack frames like synchronous platforms.

Do you read JSON from ajax post bodies? Do you access fields in that JSON without sanity checking it? Try passing JSON that's missing one of those critical fields (as, say, a griefer might do). What happened to your app?

Re:Hard-won lessons: Five years with Node.js by manyxcxi on Thursday April 20, 2017 @04:47AM (#14154988)
You nailed it. Three major things I care about for my application:

- Logging

- Metrics/Instrumentation/Tracing (memory usage, transactional performance monitoring, etc)

- Surviving exceptions

All of these are either very immature in Node or simply so far behind they may as well not exist. By nature of running in an application server, you do get a lot of benefits right off the bat for all of those, but even if you're running an executable jar instead of deploying to Tomcat stray exceptions will in almost no cases cause your application to simply die for all requests.

Also, say what you want about the verbose try/catch Exception model, but at least you can count on it. Am I getting an Error in this callback or is an exception going to get thrown? Oh, they leaked an exception when I was prepared to handle an Error and now my entire server is down. Does your process automatically restart? Not likely unless you spent a lot of time hand crafting your service to be daemonized, which is generally FAR beyond the scope of most developers I've met in any language (which also upsets me).

Re:Hard-won lessons: Five years with Node.js by NoInkling on Thursday April 20, 2017 @07:46AM (#14155803)
Promises and now async/await go a long way to remedy the discrepancy between synchronous exceptions and asynchronous errors, by helping ensure that they both end up as promise rejections (as long as promises/async functions are your de facto async abstraction) while also being handleable with try/catch. The Koa framework (and in the future Express I believe) is designed around this concept, so middleware-level promise rejections can be handled in a single place, and by default simply produce an HTTP error response. It is a shame that it's going to take a while for the Node stdlib to catch up, however.

Also I thought something like PM2 (https://github.com/Unitech/pm2) or Forever (https://github.com/foreverjs/forever) was pretty much standard for production Node apps?

Re:Hard-won lessons: Five years with Node.js by nogbit on Thursday April 20, 2017 @03:37PM (#14160060)
Spot on! And with node version 8, due out any week, we no longer needs babel on the server when doing async/await/import. It will all be there natively.

We use PM2 in production for web apps, long running processes (console apps with rethinkdb change feeds) and cron to spin up command line apps for data transformations, SaaS integrations, bots and more.

Most of us use VS Code now (I still use Vim)...so yes, having done enterprise work with a full blown IDE and tooling can be very helpful as the Node debugging and profiling experience is not great (but getting a ton better).

In the past we had a ton of C#/.net in production, then Ruby and now JS for the indefinite future. We build things that end up in production for 10 years or more, so having that talent pool to pull from in the future will be great.

Re:Hard-won lessons: Five years with Node.js by JdeBP on Thursday April 20, 2017 @07:38AM (#14155760)
If one is spending any time hand-crafting the program to daemonize itself on a Unix or a Unix-alike, one is doing things wrongly. On those operating systems, since the advent of the System Resource Controller in 1992 the right way to write a program that runs under a service manager is to write a program that runs in the normal way. No "daemonization" needed.

* http://jdebp.eu./FGA/unix-daemon-design-mistakes-to-avoid.ht...

* http://jdebp.eu./FGA/systemd-house-of-horror/

Re:Hard-won lessons: Five years with Node.js by gbuk2013 on Thursday April 20, 2017 @09:36AM (#14156462)
I for one consider that a feature - it is easy enough to write bad code in JS as it is, so anything that encourages defensive coding and solid unit/functional tests is very appropriate for this particular language.

A crash certainly draws attention to a problem much better than an error in a log that no one usually looks at.

Yes it's a pain, but you deserve it for writing buggy code and then not catching it in testing (that's what I keep saying to myself, anyway). ;)

Re:Hard-won lessons: Five years with Node.js by stickfigure on Friday April 21, 2017 @02:06AM (#14163425)
That crash, in your high-concurrency environment, produced "bad gateway" responses or closed connections for your users. I'm pretty sure they don't consider this a feature.
Re:Hard-won lessons: Five years with Node.js by m1sta_ on Thursday April 20, 2017 @01:55AM (#14154289)
If only node had exception handling and functions!
Re:Hard-won lessons: Five years with Node.js by sgift on Thursday April 20, 2017 @02:35AM (#14154441)
Node has - for me - the same problem as C#. Unchecked exceptions on every corner. You don't even know what can explode until it explodes. And then takes your Node instance down. But I am one of these weirdos who likes checked exceptions in Java, so maybe this is not a problem for others.
Re:Hard-won lessons: Five years with Node.js by mattmanser on Thursday April 20, 2017 @06:00AM (#14155332)
The same problem as C#? You're fighting a very old position.

Exception handling in C# is amazingly good, you can't run C# production level apps.

It suffers none of the problems that are being discussed above. All you're doing is confusing the discussion with a view point I haven't heard in a decade.

Re:Hard-won lessons: Five years with Node.js by NoInkling on Thursday April 20, 2017 @06:52AM (#14155575)
The default error middleware built into my framework caught it and responded with a 502.
Re:Hard-won lessons: Five years with Node.js by stickfigure on Friday April 21, 2017 @02:08AM (#14163432)
...and almost certainly left a bunch of dangling state in your app that, at best, is a memory leak.
Re:Hard-won lessons: Five years with Node.js by Can_Not on Saturday April 22, 2017 @02:24PM (#14173887)
... or almost certainly was correctly dereferenced, logged, and garbage collected.
Re:Hard-won lessons: Five years with Node.js by Can_Not on Saturday April 22, 2017 @02:26PM (#14173898)
> The default behavior for Node when there is an uncaught error is to crash the process.

What language doesn't do that?

Re:Hard-won lessons: Five years with Node.js by manyxcxi on Thursday April 20, 2017 @04:57AM (#14155046)
Love it or not, at least Python has uWSGI, which certainly helps keep things running through errors, and gives you more robust logging at a higher level, etc. if you lose your Node process it's just poof with no guarantees you'll get a good trace to pinpoint the fault.
Re:Hard-won lessons: Five years with Node.js by Can_Not on Saturday April 22, 2017 @08:19PM (#14175680)
Huh, that's weird, I've never had a Node process silently die in production without a good trace or robust high level logging. Are you sure you're​ not just making stuff up?