Comparing version 1.1.2 to 1.1.3
16
index.js
@@ -6,10 +6,12 @@ 'use strict' | ||
const asyncHooksRegEx = /\((internal\/)?async_hooks\.js:/ | ||
function cleanStack (stack) { | ||
const frames = stack.split('\n') | ||
let i = 0 | ||
while (i < 5 && frames[0] && (i < 2 || frames[0].includes('(async_hooks.js'))) { | ||
frames.shift() | ||
i++ | ||
// this part is opinionated, but it's here to avoid confusing people with internals | ||
let i = frames.length - 1 | ||
while (i && !asyncHooksRegEx.test(frames[i])) { | ||
i-- | ||
} | ||
return frames | ||
return frames.slice(i + 1, stack.length - 1) | ||
} | ||
@@ -67,3 +69,5 @@ | ||
return { | ||
stop: asyncHook.disable | ||
stop: () => { | ||
asyncHook.disable(); | ||
} | ||
} | ||
@@ -70,0 +74,0 @@ } |
{ | ||
"name": "blocked-at", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Detects node eventloop block and reports where it started", | ||
@@ -23,4 +23,4 @@ "main": "index.js", | ||
"pre-commit": "^1.2.2", | ||
"standard": "^10.0.3" | ||
"standard": "^12.0.1" | ||
} | ||
} |
@@ -10,2 +10,3 @@ 'use strict' | ||
const assert = require('assert') | ||
const sep = require('path').sep | ||
@@ -29,9 +30,9 @@ let result = [] | ||
assert(!stacks.includes('async_hooks.js'), 'Expected async_hooks.js traces not to be included') | ||
assert(stacks.includes('test/index.js:17'), 'Expected test/index.js:17 in stack trace') | ||
assert(stacks.includes('test' + sep + 'index.js:18'), 'Expected test' + sep + 'index.js:18 in stack trace') | ||
assert(stacks.includes('Server.connectionListener'), 'Expected Server.connectionListener in stack trace') | ||
assert(stacks.includes('cases/recursive.js:6'), 'Expected cases/recursive.js:6 in stack trace') | ||
assert(stacks.includes('cases/example.js:20'), 'Expected cases/example.js:20 in stack trace') | ||
assert(stacks.includes('cases/promise.js:9'), 'Expected cases/promise.js:10 in stack trace') | ||
assert(!stacks.includes('cases/falsepositive.js'), 'Expected falsepositive not to trigger a report') | ||
assert(stacks.includes('cases' + sep + 'recursive.js:6'), 'Expected cases' + sep + 'recursive.js:6 in stack trace') | ||
assert(stacks.includes('cases' + sep + 'example.js:20'), 'Expected cases' + sep + 'example.js:20 in stack trace') | ||
assert(stacks.includes('cases' + sep + 'promise.js:9'), 'Expected cases' + sep + 'promise.js:10 in stack trace') | ||
assert(!stacks.includes('cases' + sep + 'falsepositive.js'), 'Expected falsepositive not to trigger a report') | ||
console.log('OK') | ||
}, 5000) // I know it's naive, but I don't want to add mess to test cases to know when they finish |
Sorry, the diff of this file is not supported yet
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
199
11722
15