Arrow functions are with us in Node for a long time, but since the beginning I was not very confident about how much information I could get from them when debugging.

There are two facts to consider in this article. Arrow functions are anonymous and arrow functions are supposed to be short. Short code is suppose to be very readable and normally, you do not get TypeError exceptions on those functions.

But what happens if you do? Let's consider some scenarios with node v4.2.6.

Initial scenario iterates with forEach in an array and it will throw an error in a case.

var a = [ 1, 2, 3, 4, 5 ];

function iterateMe(value) {
  if (value === 5) {
    throw new Error('Hello world');
  }
}

a.forEach(iterateMe);

It will throw an error and its stack indicates function name and its location.

foo/bar.js:5
    throw new Error('Hello world');
    ^

Error: Hello world
    at iterateMe (foo/bar.js:5:11)
    at Array.forEach (native)
    at Object.<anonymous> (foo/bar.js:9:3)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

Let's rewrite code with arrow functions to generate a TypeError when cannot read a property from null value.

const a = [ 1, 2, 3, 4, 5 ];
const b = null;

const iterateMe = value => value + b[6];

a.forEach(iterateMe);

Error output display line which throws the error, but reading error stack is a little bit hard to understand error belongs to an arrow function.

foo/bar.js:4
const iterateMe = value => value + b[6];
                                    ^

TypeError: Cannot read property '6' of null
    at value (foo/bar.js:4:37)
    at Array.forEach (native)
    at Object.<anonymous> (foo/bar.js:6:3)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

Now there is nested array, nested iteration is done with functions and second iterator function will throw an error.

var a = [ [ 1, 2, 3, 4, 5 ] ];
const b = null;

function secondIterator(value) {
  return value + b[6];
}

function firstIterator(array) {
  return array.forEach(secondIterator);
}

a.forEach(firstIterator);

As first scenario, we get function names involved in the stack.

foo/bar.js:5
  return value + b[6];
                  ^

TypeError: Cannot read property '6' of null
    at secondIterator (foo/bar.js:5:19)
    at Array.forEach (native)
    at firstIterator (foo/bar.js:9:16)
    at Array.forEach (native)
    at Object.<anonymous> (foo/bar.js:12:3)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)

But if we rewrite previous code with arrow functions, it is shorter but...

const a = [ [ 1, 2, 3, 4, 5 ] ];
const b = null;

const secondIterator = value => value + b[6];
const firstIterator = array => secondIterator(array);

a.forEach(firstIterator);

..stack is harder to understand.

foo/bar.js:4
const secondIterator = value => value + b[6];
                                         ^

TypeError: Cannot read property '6' of null
    at value (foo/bar.js:4:42)
    at array (foo/bar.js:5:32)
    at Array.forEach (native)
    at Object.<anonymous> (foo/bar.js:7:3)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)

In conclusion, this problem belongs to all anonymous functions, so it is not particular for arrow functions. Arrow functions have shorter syntax to implement (most of the times) short functionality. Therefore, it would be easier to fix a bug.

But if you define complex anonymous iterators or other kind of anonymous functions and you get a long error stack to inspect, consider to name them to make your progress faster!