Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asynctrace

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asynctrace - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

package.json

@@ -21,3 +21,3 @@ {

},
"version": "1.0.6",
"version": "1.0.7",
"dependencies": {

@@ -24,0 +24,0 @@ "shimmer": ""

@@ -67,10 +67,6 @@ asynctrace

## Performance
There is a performance price with user AsyncListner, but we were able to minimize it. For example here are timing on running the full visionmedia/express test suite:
There is a performance price with using AsyncListner, but we were able to minimize it. For example here are timing on running the full visionmedia/express test suite:
```
[10:50:28 /empeeric/3party/express] time mocha --require asynctrace --require test/support/env --reporter dot --check-leaks test/ test/acceptance/
...............................................................................................................
................................................................................................................
................................................................................................................
................................................................................................................
..................................................................

@@ -80,12 +76,10 @@

real 0m8.061s
user 0m0.045s
sys 0m0.075s
[10:50:41 /empeeric/3party/express] time mocha --require test/support/env --reporter dot --check-leaks test/ test/acceptance/
...............................................................................................................
................................................................................................................
................................................................................................................
................................................................................................................
..................................................................

@@ -95,3 +89,2 @@

real 0m6.314s

@@ -98,0 +91,0 @@ user 0m0.030s

@@ -5,3 +5,3 @@ 'use strict';

describe('simple', function () {
describe('setImmediate', function () {
it('show what happens to a local Exception', function (done) {

@@ -36,7 +36,8 @@ var i = 1;

it('show what happens to a local Exception', function (done) {
it('show what happens to a exception in itertwining contexts', function (done) {
var i = 2;
var d = domain.createDomain();
d.once('error', function (e) {
expect(e.message).to.be.equal('gaga');
console.log(e.stack)
expect(e.message).to.be.equal('gaga');
expect(e.stack).to.contain('Immediate.a2');

@@ -49,3 +50,4 @@ expect(e.stack).to.contain('Immediate.b2');

d.once('error', function (e) {
expect(e.message).to.be.equal('gaga1');
console.log(e.stack)
expect(e.message).to.be.equal('gaga1');
expect(e.stack).to.contain('Immediate.a2');

@@ -79,1 +81,153 @@ expect(e.stack).to.contain('Immediate.b2');

});
describe('nextTick', function () {
it('show what happens to a local Exception', function (done) {
var i = 1;
var d = domain.createDomain();
d.once('error', function (e) {
console.log(e.stack)
expect(e.message).to.be.equal('gaga');
expect(e.stack).to.contain(' a ');
expect(e.stack).to.contain(' b ');
expect(e.stack).to.contain(' c ');
expect(e.stack).to.contain(' d ');
expect(e.stack).to.contain(' e ');
if (--i == 0) done();
});
d.run(function () {
process.nextTick(function a() {
process.nextTick(function b() {
process.nextTick(function c() {
process.nextTick(function d() {
process.nextTick(function e() {
throw new Error('gaga');
});
});
});
});
});
});
});
it('show what happens to a exception in itertwining contexts', function (done) {
var i = 2;
var d = domain.createDomain();
d.once('error', function (e) {
console.log(e.stack)
expect(e.message).to.be.equal('gaga');
expect(e.stack).to.contain(' a2 ');
expect(e.stack).to.contain(' b2 ');
expect(e.stack).to.contain(' c2 ');
expect(e.stack).to.contain(' d2 ');
expect(e.stack).to.contain(' e2 ');
--i
d.once('error', function (e) {
console.log(e.stack)
expect(e.message).to.be.equal('gaga1');
expect(e.stack).to.contain(' a2 ');
expect(e.stack).to.contain(' b2 ');
expect(e.stack).to.contain(' c2 ');
expect(e.stack).to.contain(' d21 ');
expect(e.stack).to.contain(' e21 ');
if (--i == 0) done();
});
});
d.run(function () {
process.nextTick(function a2() {
process.nextTick(function b2() {
process.nextTick(function c2() {
process.nextTick(function d2() {
process.nextTick(function e2() {
throw new Error('gaga');
});
});
process.nextTick(function d21() {
process.nextTick(function e21() {
throw new Error('gaga1');
});
});
});
});
});
});
});
});
describe('fs.readFile', function () {
var fs = require('fs');
it('show what happens to a local Exception', function (done) {
var i = 1;
var d = domain.createDomain();
d.once('error', function (e) {
console.log(e.stack)
expect(e.message).to.be.equal('gaga');
expect(e.stack).to.contain(' a ');
expect(e.stack).to.contain(' b ');
expect(e.stack).to.contain(' c ');
expect(e.stack).to.contain(' d ');
expect(e.stack).to.contain(' e ');
if (--i == 0) done();
});
d.run(function () {
fs.readFile('package.json', function a() {
fs.readFile('package.json', function b() {
fs.readFile('package.json', function c() {
fs.readFile('package.json', function d() {
fs.readFile('package.json', function e() {
throw new Error('gaga');
});
});
});
});
});
});
});
it('show what happens to a exception in itertwining contexts', function (done) {
var i = 2;
var d = domain.createDomain();
d.once('error', function (e) {
console.log(e.stack)
expect(e.message).to.be.equal('gaga');
expect(e.stack).to.contain(' a2 ');
expect(e.stack).to.contain(' b2 ');
expect(e.stack).to.contain(' c2 ');
expect(e.stack).to.contain(' d2 ');
expect(e.stack).to.contain(' e2 ');
--i
d.once('error', function (e) {
console.log(e.stack)
expect(e.message).to.be.equal('gaga1');
expect(e.stack).to.contain(' a2 ');
expect(e.stack).to.contain(' b2 ');
expect(e.stack).to.contain(' c2 ');
expect(e.stack).to.contain(' d21 ');
expect(e.stack).to.contain(' e21 ');
if (--i == 0) done();
});
});
d.run(function () {
fs.readFile('package.json', function a2() {
fs.readFile('package.json', function b2() {
fs.readFile('package.json', function c2() {
fs.readFile('package.json', function d2() {
fs.readFile('package.json', function e2() {
throw new Error('gaga');
});
});
fs.readFile('package.json', function d21() {
fs.readFile('package.json', function e21() {
throw new Error('gaga1');
});
});
});
});
});
});
});
});

@@ -13,9 +13,16 @@ 'use strict';

var BOUNDRY = ' - - - - - - async boundary - - - - - -';
var settings = {
tracingModuleStyle: null,//"\x1B[32m",
coreStyle: "\x1B[32m",
modulesStyle: "\x1B[0m",
ownStyle: "\x1B[1;4m",
mocha: true,
BOUNDRY: ' \x1B[35m[sync boundery]\x1B[0m'
}
var listener = tracing.addAsyncListener({
'create': asyncFunctionInitialized,
'before': asyncCallbackBefore,
'error': asyncCallbackError,
'after': asyncCallbackAfter
'create': asyncFunctionInitialized,
'before': asyncCallbackBefore,
'error': asyncCallbackError,
'after': asyncCallbackAfter
});

@@ -26,3 +33,3 @@

var frames = StackError.getStackFrames(asyncFunctionInitialized);
frames.push(BOUNDRY);
frames.unshift(settings.BOUNDRY);
frames.push.apply(frames, oldFrames || Error._frames);

@@ -46,3 +53,2 @@ Error._frames = frames;

var frames = (oldFrames || []).reduce(reducer, []);
frames.unshift(BOUNDRY);
error.stack += v8StackFormating('', frames);

@@ -53,25 +59,5 @@ error._passed = true;

/* ===================== stack chain manipulation ======================== */
/* ===================== stack chain util ======================== */
function isInteresting(callSite) {
var name = callSite && callSite.getFileName();
if (!name) return false;
name = name.toLowerCase();
if (!~name.indexOf(sep)) return false;
if (name.indexOf(prefix) != 0) return false;
if (~name.replace(prefix, '').indexOf('node_modules')) return false;
return true;
}
function reducer(seed, callSite) {
if (typeof callSite == 'string') {
if (callSite != seed[seed.length -1]) seed.push(callSite);
return seed;
}
if (isInteresting(callSite)) seed.push(callSite);
return seed;
}
function StackError(otp) {

@@ -92,27 +78,56 @@ Error.captureStackTrace(this, otp);

function v8StackFormating(error, frames) {
var lines = [];
lines.push(error.toString());
for (var i = 0; i < frames.length; i++) {
var frame = frames[i];
/* ===================== stack chain manipulation & formating ======================== */
function categorizeFrame(frame) {
var name = frame && frame.getFileName() && frame.getFileName().toLowerCase();
if (!name) return frame._style = settings.coreStyle;
if (name === 'tracing.js') return frame._style = settings.tracingModuleStyle;
if (!~name.indexOf(sep)) return frame._style = settings.coreStyle;
if (name.indexOf(prefix) != 0) return frame._style = settings.coreStyle;
if (~name.replace(prefix, '').indexOf('node_modules')) return frame._style = settings.modulesStyle;
frame._style = settings.ownStyle;
}
function reducer(seed, frame) {
if (typeof frame == 'string') {
lines.push(frame);
continue;
if (frame != seed[seed.length - 1]) seed.push(frame);
return seed;
}
var line;
try {
line = frame.toString();
} catch (e) {
try {
line = "<error: " + e + ">";
} catch (ee) {
// Any code that reaches this point is seriously nasty!
line = "<error>";
}
categorizeFrame(frame);
seed.push(frame);
return seed;
}
function v8StackFormating(error, frames) {
var lines = [];
lines.push(error.toString());
frames.push({toString: function () { return '<the nexus>\n'; _style: settings.ownStyle }});
for (var i = 0; i < frames.length; i++) {
var frame = frames[i];
if (typeof frame == 'string') {
lines.push(frame);
continue;
}
var line;
try {
line = frame.toString();
} catch (e) {
try {
line = "<error: " + e + ">";
} catch (ee) {
// Any code that reaches this point is seriously nasty!
line = "<error>";
}
}
var prefix = frame._style + " at ";
var suffix = "\x1B[0m";
if (frame._style) lines.push(prefix + line + suffix);
}
lines.push(" at " + line);
}
return lines.join("\n");
return lines.join("\n");
}
/* ===================== 3rd party integrations ======================== */
function setupForMocha() {

@@ -132,2 +147,2 @@ try {

}
setupForMocha();
if (settings.forMocha) setupForMocha();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc