From 27f679a883e026bd43de30e149a508fc765a82fc Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Mon, 5 Jan 2015 12:23:14 +0000 Subject: [PATCH 1/7] Adds repository entry to package.json ...to quieten this sort of thing when installing a module with a dependency on stackup: ```sh npm WARN package.json stackup@0.0.5 No repository field. ``` --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 07a0623..33dae9d 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "main": "longtrace.js", "author": "Jacob Groundwater ", "license": "MIT", + "repository": { + "type": "git", + "url": "git://github.com/groundwater/node-stackup.git" + }, "dependencies": { "async-listener": "~0.2.2" } From d6fbce2eb1c4fbb5c52fd9032165ea28c0265b98 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Wed, 7 Jan 2015 11:36:22 -0800 Subject: [PATCH 2/7] bump async-listner to 0.4.7 --- index.js | 19 +++++++++---------- package.json | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 8557f79..1f5044f 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ 'use strict'; -if(!process.addAsyncListener) +if(!process.addAsyncListener) require('async-listener'); var util = require('util'); var TraceModule = require('./trace')(Error, __dirname + '/node_modules/async-listener'); @@ -12,17 +12,16 @@ var activeTrace; // -- async listener -- // -// each time an async event is scheduled, i.e. setImmediate, or -// process.nextTick, etc. we capture the stack at that exact point -// this is going to be a crap ton of stack traces, but it will be -// very accurate! -function asyncListener() { - return TraceModule.NewWithParent(activeTrace, asyncListener); -} - // the async handler glues the previous stack trace to // the next one var asyncHandlers = { + create : function create() { + // each time an async event is scheduled, i.e. setImmediate, or + // process.nextTick, etc. we capture the stack at that exact point + // this is going to be a crap ton of stack traces, but it will be + // very accurate! + return TraceModule.NewWithParent(activeTrace, create); + }, before : function before(context, trace) { // activeTrace is used to link child traces to their parents activeTrace = trace; @@ -41,4 +40,4 @@ var asyncHandlers = { } } -process.addAsyncListener(asyncListener, asyncHandlers); +process.addAsyncListener(asyncHandlers); diff --git a/package.json b/package.json index 07a0623..e34880f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,6 @@ "author": "Jacob Groundwater ", "license": "MIT", "dependencies": { - "async-listener": "~0.2.2" + "async-listener": "~0.4.7" } } From aad7c8d2c032968b1706608e3ce0f8499f4439d0 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Thu, 8 Jan 2015 14:12:49 -0800 Subject: [PATCH 3/7] 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e34880f..1366360 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stackup", - "version": "0.0.5", + "version": "1.0.0", "description": "Long stack traces based on async listeners", "main": "longtrace.js", "author": "Jacob Groundwater ", From 0f1196d5ae991d4ca64dc280a9caf461883c9db4 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Mon, 11 May 2015 14:02:18 -0700 Subject: [PATCH 4/7] none recursive --- trace.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/trace.js b/trace.js index 7f33798..f2082af 100644 --- a/trace.js +++ b/trace.js @@ -1,6 +1,6 @@ var util = require('util'); -function Trace(module){ +function Trace(module) { this.module = module; this.parent = null; this.stack = null; @@ -9,16 +9,22 @@ function Trace(module){ Trace.prototype.toString = function toString(stack) { var out = []; - if (stack) out.push(this.__filter(stack.split(/\n+/)).join('\n')); - if (this.stack) out.push(this.__format(this.stack.stack)); - if (this.parent) out.push(this.parent.toString()); + if (stack) out.push(this.__filter(stack.split(/\n+/)).join('\n')); + if (this.stack) out.push(this.__format(this.stack.stack)); + + var current = this.parent; + + while (current) { + if (current.stack) out.push(current.__format(current.stack.stack)); + current = current.parent; + } return out.join('\n'); } Trace.prototype.__format = function __format(stack) { var split = stack.split(/\n+/); - + // get rid of [object Object] line split.shift(); split.unshift(' ---- async ----'); @@ -56,7 +62,7 @@ TraceModule.prototype.NewWithParent = function NewWithParent(parent, omit) { var trace = this.New(); var omitStack = omit || NewWithParent; var stack = {}; - + this.Error.captureStackTrace(stack, omitStack); trace.parent = parent; @@ -68,4 +74,3 @@ TraceModule.prototype.NewWithParent = function NewWithParent(parent, omit) { module.exports = function (Error, filter) { return new TraceModule(Error, filter); } - From 66cc1fd3b19aee96604c211b02c42807c1a90b16 Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Mon, 11 May 2015 14:43:57 -0700 Subject: [PATCH 5/7] 1.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e6858b7..21333df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stackup", - "version": "1.0.0", + "version": "1.0.1", "description": "Long stack traces based on async listeners", "main": "longtrace.js", "author": "Jacob Groundwater ", From 48a549273ac902d1c13719ccb18dbdda29936717 Mon Sep 17 00:00:00 2001 From: Ben Gourley Date: Thu, 24 Aug 2017 15:24:21 +0100 Subject: [PATCH 6/7] Dynamically figure out async-listener location from require.resolve npm doesn't always install async-listener as a nested dependency of this module, so look it up using the same algorithm as require() to ensure the stack frames are correctly filtered. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1f5044f..32aef6a 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,8 @@ if(!process.addAsyncListener) require('async-listener'); -var util = require('util'); -var TraceModule = require('./trace')(Error, __dirname + '/node_modules/async-listener'); +var path = require('path'); +var TraceModule = require('./trace')(Error, path.dirname(require.resolve('async-listener'))); Error.stackTraceLimit = Infinity; From ee6d610be74752db8b06343b0794203b18a84f74 Mon Sep 17 00:00:00 2001 From: Jacob Groundwater Date: Wed, 30 Aug 2017 09:46:48 -0700 Subject: [PATCH 7/7] 1.0.2 --- package-lock.json | 21 +++++++++++++++++++++ package.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..52bee8d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,21 @@ +{ + "name": "stackup", + "version": "1.0.2", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "async-listener": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.4.7.tgz", + "integrity": "sha1-DY45ALMY4tY8WHGCIRoe7zu1u4I=", + "requires": { + "shimmer": "1.0.0" + } + }, + "shimmer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.0.0.tgz", + "integrity": "sha1-ScLXHGeDYLgCvhiyeDgtHLuAXDk=" + } + } +} diff --git a/package.json b/package.json index 21333df..57b6718 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stackup", - "version": "1.0.1", + "version": "1.0.2", "description": "Long stack traces based on async listeners", "main": "longtrace.js", "author": "Jacob Groundwater ",