Skip to content


wrong stack trace #10

wants to merge 1 commit into from

1 participant


Hi —

Working with dnode, I commonly run into an error where I get the "wrong" stack trace. I can reproduce it pretty easily, by editing one of the examples in the repo.

    window.onload = function () {
        DNode.connect(function (remote) {
   (says) {
                throw 42;

In the console, instead of seeing a useful stack trace, I see:

Error: Uncaught, unspecified 'error' event. ( Worse, the line number is wrong. (meaning, it is not the line that's responsible for throwing the error.)

This can be annoying, especially when one is working on a project that's less trivial, because one has no idea what line number actually threw the error.

Poking around, I found out that the two try/catch statements in dnode-protocol we actually responsible for masking the line number for the error. My instinct tells me that those try/catch are there for a good reason, but (at least during active development), I want to know where my errors are coming from.

@humanchimp humanchimp closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 2 additions and 4 deletions.
  1. +2 −4 index.js
6 index.js
@@ -78,8 +78,7 @@ var Session = exports.Session = function (id, wrapper) {
- try { self.handle(msg) }
- catch (err) { self.emit('error', err) }
+ self.handle(msg);
self.handle = function (req) {
@@ -140,8 +139,7 @@ var Session = exports.Session = function (id, wrapper) {
function apply(f, obj, args) {
- try { f.apply(obj, args) }
- catch (err) { self.emit('error', err) }
+ f.apply(obj, args);
return self;
Something went wrong with that request. Please try again.