diff --git a/source-map-support.js b/source-map-support.js index fe21a9a..13cdf0c 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -270,6 +270,10 @@ function CallSiteToString() { var isMethodCall = !(this.isToplevel() || isConstructor); if (isMethodCall) { var typeName = this.getTypeName(); + // Fixes shim to be backward compatable with Node v0 to v4 + if (typeName === "[object Object]") { + typeName = "null"; + } var methodName = this.getMethodName(); if (functionName) { if (typeName && functionName.indexOf(typeName) != 0) { diff --git a/test.js b/test.js index 1179f5e..583dedd 100644 --- a/test.js +++ b/test.js @@ -259,6 +259,21 @@ it('throw with empty source map', function() { ]); }); +it('throw in Timeout with empty source map', function(done) { + compareStdout(done, createEmptySourceMap(), [ + 'require("./source-map-support").install();', + 'setTimeout(function () {', + ' throw new Error("this is the error")', + '})' + ], [ + /\/.generated.js:3$/, + ' throw new Error("this is the error")', + /^ \^$/, + 'Error: this is the error', + /^ at ((null)|(Timeout))\._onTimeout \((?:.*\/)?.generated.js:3:11\)$/ + ]); +}); + it('throw with source map with gap', function() { compareStackTrace(createSourceMapWithGap(), [ 'throw new Error("test");'