Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncaughtException masked #1438

Closed
ghost opened this issue Jun 14, 2011 · 11 comments
Closed

uncaughtException masked #1438

ghost opened this issue Jun 14, 2011 · 11 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 14, 2011

I cant get this scrpt to work using the latest Node and latest CoffeeScript

process.removeAllListeners 'uncaughtException'
process.on 'uncaughtException', (er) ->
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  return

throw new Error("aAH")

Running coffee test.coffee just throws the normal stacktrace.

Howver the generated test.js (from coffee compile) works as planned with node test.generated.js

@ghost
Copy link
Author

ghost commented Jun 14, 2011

Same issue on Ubuntu linux server.

coffee test.coffee - No console.log, just normal strack trace output
however:
coffee -c test.coffee; node test.js - works as expected

@TrevorBurnham
Copy link
Collaborator

I just posted an answer to your StackOverflow question on this:
http://stackoverflow.com/questions/6346291/nodejs-and-coffeescript-coffee-executable-not-behaving-the-same/6350100#6350100

This behavior is intentional—if the exception trickled all the way down to the process level, the coffee process itself would crash. That may seem desirable when running coffee test.coffee, but suppose that you ran coffee -w test.coffee (which runs test.coffee every time it changes); because coffee catches errors in test.coffee, you don't have to restart it every time your code generates a runtime error.

So, you should compile to JS and re-run that JS every time it changes. You could write a Cakefile to do that (the most versatile option, but requires some legwork), or just use coffee -cw test.coffee in conjunction with node-supervisor.

@wavded
Copy link

wavded commented Dec 7, 2011

Why not enable this for coffee test.coffee, nobody wants to have compiled JS just sitting around in their directory just for sake of having being able to handle 'uncaughtExceptions' when they have a CS project, or going through the overhead of setting up a Cakefile. How to suggest a production deployment then? Right now for me its upstart that runs the coffee command and respawns, but it sucks that I'm not getting that valuable exception information.

Peeved, nothing personal but it just seems like the current workaround isn't a very good one unless I'm misunderstanding something. I want coffee to crash if an error happens and right now it does crash for an uncaughtException but it sucks up the valuable exception information. Plz advice.

@wavded
Copy link

wavded commented Dec 7, 2011

oddly enough, sometimes it seems to allow it, i'm confused... this case is broken and I've been able to verify as well... winstonjs/winston#47

@brandonbloom
Copy link

I was just bitten by this as well. Exceptions thrown from the top level don't trigger uncaughtException, but they do if I wrap the throw in a setTimeout

@aventuralabs
Copy link

This causes problems with most server-side error handlers, such as Sentry.

@maletor
Copy link

maletor commented Jan 15, 2014

And bugsnag.

@Nowaker
Copy link

Nowaker commented Apr 18, 2014

Indeed.

@max-degterev
Copy link

We're using coffee executable on the server. We're catching most of our errors with domain. Is this still an issue we should be aware about? We wanted to use bugsnag and their docs refer to this page.

@a7madgamal
Copy link

"We wanted to use bugsnag and their docs refer to this page"
still the case in 2016!

@Nowaker
Copy link

Nowaker commented May 11, 2016

As we can see, CoffeeScript isn't for serious production deployments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants