Comparing version 0.5.7 to 0.6.0
42
index.js
@@ -39,10 +39,19 @@ 'use strict'; | ||
(function () { | ||
var _Error_prepareStackTrace = Error.prepareStackTrace; | ||
var hooked = function (_, stack) { return stack; }; | ||
function getStack() { | ||
Error.prepareStackTrace = hooked | ||
var _Error_prepareStackTrace = Error.prepareStackTrace; | ||
Error.prepareStackTrace = hooked; | ||
var err = new Error(); | ||
var stack = err.stack.map(function (item) { | ||
if (item.isEval()) { | ||
var matched = item.getEvalOrigin().match(/\((.*):(\d*):(\d*)\)/) || {}; | ||
return { | ||
name: '<eval>', | ||
file: matched[1], | ||
line: matched[2] | ||
}; | ||
} | ||
return { | ||
name: item.getFunctionName(), | ||
file: item.getFileName(), | ||
@@ -59,2 +68,3 @@ line: item.getLineNumber() | ||
// Ignore frames from: | ||
// - null/undefined values | ||
// - wtfnode by excluding __filename | ||
@@ -64,3 +74,4 @@ // - builtins by excluding files with no path separator | ||
// (even on windows, the stack trace uses unix separators for these) | ||
if (stack[i].file !== __filename && | ||
if (stack[i].file && | ||
stack[i].file !== __filename && | ||
stack[i].file.indexOf(path.sep) !== -1 && | ||
@@ -118,2 +129,3 @@ stack[i].file.slice(0, 9) !== 'internal/' | ||
// this should inherit 'name' and 'length' and any other properties that have been assigned | ||
// also inherits prototype, and symbols like the promisify value! | ||
copyProperties(fn, wrapped); | ||
@@ -317,7 +329,7 @@ | ||
if (!thing.__callSite) { | ||
var name = ((thing.name ? thing.name : thing.constructor.name) || 'unknown').trim(); | ||
var name = ((thing.name ? thing.name : thing.constructor.name) || '(anonymous)').trim(); | ||
if (!DONT_INSTRUMENT[name]) { | ||
console.warn('Unable to determine callsite for "'+name+'". Did you require `wtfnode` at the top of your entry point?'); | ||
} | ||
return { file: 'unknown', line: 0 }; | ||
return { name: '(anonymous)', file: 'unknown', line: 0 }; | ||
} | ||
@@ -367,3 +379,3 @@ return thing.__callSite; | ||
var callSite = getCallsite(fn); | ||
console.log(' - %s: %s @ %s:%d', 'keypress', fn.name || '(anonymous)', callSite.file, callSite.line); | ||
console.log(' - %s: %s @ %s:%d', 'keypress', fn.name || fn.__name || callSite.name || '(anonymous)', callSite.file, callSite.line); | ||
}); | ||
@@ -434,3 +446,3 @@ } | ||
var callSite = getCallsite(fn); | ||
console.log(' - %s: %s @ %s:%d', 'connect', fn.name || '(anonymous)', callSite.file, callSite.line); | ||
console.log(' - %s: %s @ %s:%d', 'connect', fn.name || fn.__name || callSite.name || '(anonymous)', callSite.file, callSite.line); | ||
}); | ||
@@ -480,3 +492,3 @@ } | ||
var callSite = getCallsite(fn); | ||
console.log(' - %s: %s @ %s:%d', eventType, fn.__name || fn.name || '(anonymous)', callSite.file, callSite.line); | ||
console.log(' - %s: %s @ %s:%d', eventType, fn.name || fn.__name || callSite.name || '(anonymous)', callSite.file, callSite.line); | ||
}); | ||
@@ -533,7 +545,4 @@ } | ||
callSite = getCallsite(fn); | ||
if (fn.__name) { | ||
console.log(' - (%d ~ %s) %s @ %s:%d', t._idleTimeout, formatTime(t._idleTimeout), fn.__name, callSite.file, callSite.line); | ||
} else { | ||
console.log(' - (%d ~ %s) %s @ %s:%d', t._idleTimeout, formatTime(t._idleTimeout), fn.name, callSite.file, callSite.line); | ||
} | ||
console.log(' - (%d ~ %s) %s @ %s:%d', t._idleTimeout, formatTime(t._idleTimeout), fn.name || fn.__name || callSite.name || '(anonymous)', callSite.file, callSite.line); | ||
}); | ||
@@ -548,7 +557,4 @@ } | ||
callSite = getCallsite(fn); | ||
if (fn.__name) { | ||
console.log(' - (%d ~ %s) %s @ %s:%d', t._idleTimeout, formatTime(t._idleTimeout), fn.__name, callSite.file, callSite.line); | ||
} else { | ||
console.log(' - (%d ~ %s) %s @ %s:%d', t._idleTimeout, formatTime(t._idleTimeout), fn.name, callSite.file, callSite.line); | ||
} | ||
console.log(' - (%d ~ %s) %s @ %s:%d', t._idleTimeout, formatTime(t._idleTimeout), fn.name || fn.__name || callSite.name, callSite.file, callSite.line); | ||
}); | ||
@@ -555,0 +561,0 @@ } |
{ | ||
"name": "wtfnode", | ||
"version": "0.5.7", | ||
"version": "0.6.0", | ||
"description": "Utility to help find out why Node isn't exiting", | ||
@@ -10,4 +10,11 @@ "repository": { | ||
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"proxy.js", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "(cd tests && node test && node test-eval && node test-promisify)", | ||
"test-sourcemaps": "(cd tests && coffee --map --compile test-sourcemaps.coffee && node test-sourcemaps.js || exit 0)", | ||
"kitchensink": "(cd tests && node kitchensink)" | ||
}, | ||
@@ -18,3 +25,7 @@ "author": "Kris Reeves", | ||
}, | ||
"license": "ISC" | ||
"license": "ISC", | ||
"devDependencies": { | ||
"coffee-script": "^1.12.7", | ||
"source-map-support": "^0.5.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
2
2
9
27041
2
4
551