Comparing version 1.9.0 to 1.9.1
28
index.js
@@ -9,2 +9,5 @@ 'use strict'; | ||
var APP_NAME_REGEX = /^[A-Za-z0-9 -_\[\](){}?!.'"]*$/; | ||
try { | ||
@@ -43,8 +46,8 @@ logger.debug("Process was running %s seconds before agent was loaded.", | ||
agent = new Agent(config); | ||
var appNames = agent.config.applications(); | ||
if (agent.config.applications().length < 1) { | ||
if (appNames.length < 1) { | ||
message = "New Relic requires that you name this application!\n" + | ||
"Set app_name in your newrelic.js file or set environment variable\n" + | ||
"NEW_RELIC_APP_NAME. Not starting!"; | ||
logger.error(message); | ||
@@ -54,2 +57,23 @@ throw new Error(message); | ||
var testVal; | ||
appNames.forEach(function (name) { | ||
testVal = name.match(APP_NAME_REGEX); | ||
if (!testVal){ | ||
message = "New Relic requires that you name this application using alphanumeric" + | ||
" and certain punctuation characters ([](){}.?!') only.\n" + | ||
"Reset app_name to follow these naming conventions " + | ||
"in your newrelic.js file or set environment variable\n" + | ||
"NEW_RELIC_APP_NAME. Not starting!"; | ||
config.agent_enabled = false; | ||
config.emit('agent_enabled', false); | ||
logger.error(message); | ||
console.log(message); | ||
} | ||
}); | ||
var shimmer = require(path.join(__dirname, 'lib', 'shimmer.js')); | ||
@@ -56,0 +80,0 @@ shimmer.patchModule(agent); |
@@ -22,4 +22,4 @@ 'use strict'; | ||
var CONFIG_FILE_LOCATIONS = [ | ||
process.env.NEW_RELIC_HOME, | ||
process.cwd(), | ||
process.env.NEW_RELIC_HOME, | ||
process.env.HOME, | ||
@@ -31,3 +31,3 @@ path.join(__dirname, '..', '..', '..') // above node_modules | ||
if (process.mainModule && process.mainModule.filename) { | ||
CONFIG_FILE_LOCATIONS.splice(1, 0, path.dirname(process.mainModule.filename)); | ||
CONFIG_FILE_LOCATIONS.splice(2, 0, path.dirname(process.mainModule.filename)); | ||
} | ||
@@ -34,0 +34,0 @@ |
@@ -65,3 +65,3 @@ 'use strict'; | ||
var start = parseInt(qtime); | ||
var start = parseFloat(qtime); | ||
@@ -68,0 +68,0 @@ if (isNaN(start)) { |
@@ -32,3 +32,3 @@ 'use strict'; | ||
function _patchErrorTracerOntoCLS(agent, namespace) { | ||
var callbacks = namespace && namespace.id && namespace.id.callbacks; | ||
var callbacks = namespace && namespace.id; | ||
if (callbacks && callbacks.error) { | ||
@@ -35,0 +35,0 @@ callbacks.error = function cb_error(domain, error) { |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
app_name : ['My Application'], | ||
app_name : ['éxample'], | ||
/** | ||
@@ -14,0 +14,0 @@ * Your New Relic license key. |
14
NEWS.md
@@ -0,1 +1,15 @@ | ||
### v1.9.1 (2014-07-30): | ||
* Added a check for invalid characters in the `app_name` setting. | ||
The agent will now emit a warning and disable itself if any application name | ||
is invalid. Allowed characters are alphanumerics and certain punctuation | ||
characters ([](){}.?!') | ||
* Router queue time now properly handles floating point values. | ||
* Fixed a bug where a socket connection could throw a synchronous error and | ||
cause the application to crash. | ||
### v1.9.0 (2014-07-24): | ||
@@ -2,0 +16,0 @@ |
@@ -0,1 +1,5 @@ | ||
### v3.1.0 (2014-07-28): | ||
* Updated to use `async-listener@0.4.7` to pick up bug fixes. | ||
### v3.0.0 (2013-12-14): | ||
@@ -2,0 +6,0 @@ |
@@ -165,10 +165,8 @@ 'use strict'; | ||
var namespace = new Namespace(name); | ||
namespace.id = process.addAsyncListener( | ||
function () { return namespace.active; }, | ||
{ | ||
before : function (context, domain) { if (domain) namespace.enter(domain); }, | ||
after : function (context, domain) { if (domain) namespace.exit(domain); }, | ||
error : function (domain) { if (domain) namespace.exit(domain); } | ||
} | ||
); | ||
namespace.id = process.addAsyncListener({ | ||
create : function () { return namespace.active; }, | ||
before : function (context, storage) { if (storage) namespace.enter(storage); }, | ||
after : function (context, storage) { if (storage) namespace.exit(storage); }, | ||
error : function (storage) { if (storage) namespace.exit(storage); } | ||
}); | ||
@@ -175,0 +173,0 @@ namespaces[name] = namespace; |
var wrap = require('shimmer').wrap; | ||
/* | ||
* | ||
* CONSTANTS | ||
* | ||
*/ | ||
var HAS_CREATE_AL = 1 << 0; | ||
var HAS_BEFORE_AL = 1 << 1; | ||
var HAS_AFTER_AL = 1 << 2; | ||
var HAS_ERROR_AL = 1 << 3; | ||
/** | ||
@@ -109,7 +119,7 @@ * There is one list of currently active listeners that is mutated in place by | ||
for (var i = 0; i < length; ++i) { | ||
if (!listeners[i].callbacks) continue; | ||
var listener = listeners[i]; | ||
if ((listener.flags & HAS_ERROR_AL) === 0) continue; | ||
var error = listeners[i].callbacks.error; | ||
var value = errorValues && errorValues[i]; | ||
if (typeof error === 'function') handled = error(value, er) || handled; | ||
var value = errorValues && errorValues[listener.uid]; | ||
handled = listener.error(value, er) || handled; | ||
} | ||
@@ -136,8 +146,9 @@ inErrorTick = false; | ||
for (var i = 0; i < length; ++i) { | ||
/* asyncListener.domain is the default value passed through before and | ||
* after if the listener doesn't return a value. | ||
*/ | ||
values[i] = list[i].domain; | ||
var value = list[i].listener.call(this); | ||
if (typeof value !== 'undefined') values[i] = value; | ||
var listener = list[i]; | ||
values[listener.uid] = listener.data; | ||
if ((listener.flags & HAS_CREATE_AL) === 0) continue; | ||
var value = listener.create(listener.data); | ||
if (value !== undefined) values[listener.uid] = value; | ||
} | ||
@@ -154,3 +165,2 @@ inAsyncTick = false; | ||
return function () { | ||
// put the current values where the catcher can see them | ||
@@ -174,4 +184,5 @@ errorValues = values; | ||
for (var i = 0; i < length; ++i) { | ||
var before = list[i].callbacks && list[i].callbacks.before; | ||
if (typeof before === 'function') before(this, values[i]); | ||
if ((list[i].flags & HAS_BEFORE_AL) > 0) { | ||
list[i].before(this, values[list[i].uid]); | ||
} | ||
} | ||
@@ -188,4 +199,5 @@ inAsyncTick = false; | ||
for (i = 0; i < length; ++i) { | ||
var after = list[i].callbacks && list[i].callbacks.after; | ||
if (typeof after === 'function') after(this, values[i], returned); | ||
if ((list[i].flags & HAS_AFTER_AL) > 0) { | ||
list[i].after(this, values[list[i].uid]); | ||
} | ||
} | ||
@@ -234,4 +246,5 @@ inAsyncTick = false; | ||
for (var i = 0; i < length; ++i) { | ||
var error = listeners[i].callbacks && listeners[i].callbacks.error; | ||
if (typeof error === 'function') handled = error(undefined, er) || handled; | ||
var listener = listeners[i]; | ||
if ((listener.flags & HAS_ERROR_AL) === 0) continue; | ||
handled = listener.error(null, er) || handled; | ||
} | ||
@@ -253,8 +266,9 @@ | ||
for (var i = 0; i < length; ++i) { | ||
/* asyncListener.domain is the default value passed through before and | ||
* after if the listener doesn't return a value. | ||
*/ | ||
values[i] = list[i].domain; | ||
var value = list[i].listener.call(this); | ||
if (typeof value !== 'undefined') values[i] = value; | ||
var listener = list[i]; | ||
values[listener.uid] = listener.data; | ||
if ((listener.flags & HAS_CREATE_AL) === 0) continue; | ||
var value = listener.create(listener.data); | ||
if (value !== undefined) values[listener.uid] = value; | ||
} | ||
@@ -294,4 +308,5 @@ inAsyncTick = false; | ||
for (var i = 0; i < length; ++i) { | ||
var before = list[i].callbacks && list[i].callbacks.before; | ||
if (typeof before === 'function') before(this, values[i]); | ||
if ((list[i].flags & HAS_BEFORE_AL) > 0) { | ||
list[i].before(this, values[list[i].uid]); | ||
} | ||
} | ||
@@ -308,12 +323,10 @@ inAsyncTick = false; | ||
for (var i = 0; i < length; ++i) { | ||
var error = listeners[i].callbacks.error; | ||
if (typeof error === 'function') { | ||
try { | ||
handled = error(values[i], er) || handled; | ||
} | ||
catch (x) { | ||
errorThrew = true; | ||
throw x; | ||
} | ||
if ((listeners[i].flags & HAS_ERROR_AL) > 0) continue; | ||
try { | ||
handled = listeners[i].error(values[list[i].uid], er) || handled; | ||
} | ||
catch (x) { | ||
errorThrew = true; | ||
throw x; | ||
} | ||
} | ||
@@ -338,4 +351,5 @@ | ||
for (i = 0; i < length; ++i) { | ||
var after = list[i].callbacks && list[i].callbacks.after; | ||
if (typeof after === 'function') after(this, values[i], returned); | ||
if ((list[i].flags & HAS_AFTER_AL) > 0) { | ||
list[i].after(this, values[list[i].uid]); | ||
} | ||
} | ||
@@ -361,3 +375,6 @@ inAsyncTick = false; | ||
inAsyncTick = true; | ||
for (var i = 0; i < length; ++i) list[i].listener(); | ||
for (var i = 0; i < length; ++i) { | ||
var listener = list[i]; | ||
if (listener.create) listener.create(listener.data); | ||
} | ||
inAsyncTick = false; | ||
@@ -395,3 +412,3 @@ | ||
for (var i = 0; i < length; ++i) { | ||
if (list[i].callbacks) return asyncWrap(original, list, length); | ||
if (list[i].flags > 0) return asyncWrap(original, list, length); | ||
} | ||
@@ -402,24 +419,60 @@ | ||
function createAsyncListener(listener, callbacks, value) { | ||
return { | ||
listener : listener, | ||
callbacks : callbacks, | ||
domain : value, | ||
uid : uid++ | ||
}; | ||
function AsyncListener(callbacks, data) { | ||
if (typeof callbacks.create === 'function') { | ||
this.create = callbacks.create; | ||
this.flags |= HAS_CREATE_AL; | ||
} | ||
if (typeof callbacks.before === 'function') { | ||
this.before = callbacks.before; | ||
this.flags |= HAS_BEFORE_AL; | ||
} | ||
if (typeof callbacks.after === 'function') { | ||
this.after = callbacks.after; | ||
this.flags |= HAS_AFTER_AL; | ||
} | ||
if (typeof callbacks.error === 'function') { | ||
this.error = callbacks.error; | ||
this.flags |= HAS_ERROR_AL; | ||
} | ||
this.uid = ++uid; | ||
this.data = data === undefined ? null : data; | ||
} | ||
AsyncListener.prototype.create = undefined; | ||
AsyncListener.prototype.before = undefined; | ||
AsyncListener.prototype.after = undefined; | ||
AsyncListener.prototype.error = undefined; | ||
AsyncListener.prototype.data = undefined; | ||
AsyncListener.prototype.uid = 0; | ||
AsyncListener.prototype.flags = 0; | ||
function addAsyncListener(listener, callbacks, value) { | ||
var asyncListener; | ||
if (typeof listener === 'function') { | ||
asyncListener = createAsyncListener(listener, callbacks, value); | ||
function createAsyncListener(callbacks, data) { | ||
if (typeof callbacks !== 'object' || !callbacks) { | ||
throw new TypeError('callbacks argument must be an object'); | ||
} | ||
if (callbacks instanceof AsyncListener) { | ||
return callbacks; | ||
} | ||
else { | ||
asyncListener = listener; | ||
return new AsyncListener(callbacks, data); | ||
} | ||
} | ||
// Make sure the asyncListener isn't already in the list. | ||
function addAsyncListener(callbacks, data) { | ||
var listener; | ||
if (!(callbacks instanceof AsyncListener)) { | ||
listener = createAsyncListener(callbacks, data); | ||
} | ||
else { | ||
listener = callbacks; | ||
} | ||
// Make sure the listener isn't already in the list. | ||
var registered = false; | ||
for (var i = 0; i < listeners.length; i++) { | ||
if (asyncListener.uid === listeners[i].uid) { | ||
if (listener === listeners[i]) { | ||
registered = true; | ||
@@ -430,5 +483,5 @@ break; | ||
if (!registered) listeners.push(asyncListener); | ||
if (!registered) listeners.push(listener); | ||
return asyncListener; | ||
return listener; | ||
} | ||
@@ -438,3 +491,3 @@ | ||
for (var i = 0; i < listeners.length; i++) { | ||
if (listener.uid === listeners[i].uid) { | ||
if (listener === listeners[i]) { | ||
listeners.splice(i, 1); | ||
@@ -441,0 +494,0 @@ break; |
@@ -65,3 +65,5 @@ 'use strict'; | ||
this.on('connection', function (socket) { | ||
socket._handle.onread = wrapCallback(socket._handle.onread); | ||
if (socket._handle) { | ||
socket._handle.onread = wrapCallback(socket._handle.onread); | ||
} | ||
}); | ||
@@ -86,3 +88,5 @@ | ||
var result = original.apply(this, args); | ||
this._handle.onread = wrapCallback(this._handle.onread); | ||
if (this._handle) { | ||
this._handle.onread = wrapCallback(this._handle.onread); | ||
} | ||
return result; | ||
@@ -89,0 +93,0 @@ }; |
{ | ||
"name": "async-listener", | ||
"version": "0.4.5", | ||
"version": "0.4.7", | ||
"description": "Polyfill exporting trevnorris's 0.11+ asyncListener API.", | ||
@@ -47,10 +47,8 @@ "author": { | ||
}, | ||
"gitHead": "3f5dd46101096d595f73d83d7aa02d0096ed2e5f", | ||
"homepage": "https://github.com/othiym23/async-listener", | ||
"_id": "async-listener@0.4.5", | ||
"dist": { | ||
"shasum": "ea246828799b39db40af0822f6acd5efbd3044ab", | ||
"tarball": "http://registry.npmjs.org/async-listener/-/async-listener-0.4.5.tgz" | ||
}, | ||
"_from": "async-listener@0.4.5", | ||
"_npmVersion": "1.3.14", | ||
"_id": "async-listener@0.4.7", | ||
"_shasum": "0d8e3900b318e2d63c587182211a1eef3bb5bb82", | ||
"_from": "async-listener@0.4.7", | ||
"_npmVersion": "2.0.0-alpha-5", | ||
"_npmUser": { | ||
@@ -66,5 +64,9 @@ "name": "othiym23", | ||
], | ||
"dist": { | ||
"shasum": "0d8e3900b318e2d63c587182211a1eef3bb5bb82", | ||
"tarball": "http://registry.npmjs.org/async-listener/-/async-listener-0.4.7.tgz" | ||
}, | ||
"directories": {}, | ||
"_shasum": "ea246828799b39db40af0822f6acd5efbd3044ab", | ||
"_resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.4.5.tgz" | ||
"_resolved": "https://registry.npmjs.org/async-listener/-/async-listener-0.4.7.tgz", | ||
"readme": "ERROR: No README data found!" | ||
} |
@@ -13,4 +13,4 @@ 'use strict'; | ||
var listener = process.createAsyncListener( | ||
function () { counted++; }, | ||
{ | ||
create : function () { counted++; }, | ||
before : function () {}, | ||
@@ -17,0 +17,0 @@ after : function () {}, |
@@ -28,2 +28,5 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
var active = null; | ||
var cntr = 0; | ||
function onAsync0() { | ||
@@ -37,18 +40,36 @@ return 0; | ||
function onError(stor) { | ||
results.push(stor); | ||
return true; | ||
} | ||
var results = []; | ||
var asyncNoHandleError = { | ||
error: function (stor) { | ||
results.push(stor); | ||
return true; | ||
} | ||
var asyncNoHandleError0 = { | ||
create: onAsync0, | ||
error: onError | ||
}; | ||
var asyncNoHandleError1 = { | ||
create: onAsync1, | ||
error: onError | ||
}; | ||
var listeners = [ | ||
process.addAsyncListener(onAsync0, asyncNoHandleError), | ||
process.addAsyncListener(onAsync1, asyncNoHandleError) | ||
process.addAsyncListener(asyncNoHandleError0), | ||
process.addAsyncListener(asyncNoHandleError1) | ||
]; | ||
function expect2Errors() { | ||
process.nextTick(function() { | ||
throw new Error(); | ||
}); | ||
// handling of errors should propagate to all listeners | ||
process.removeAsyncListener(listeners[0]); | ||
process.removeAsyncListener(listeners[1]); | ||
process.on('exit', function(code) { | ||
// If the exit code isn't ok then return early to throw the stack that | ||
// caused the bad return code. | ||
if (code !== 0) | ||
return; | ||
// Handling of errors should propagate to all listeners. | ||
assert.equal(results[0], 0); | ||
@@ -59,11 +80,2 @@ assert.equal(results[1], 1); | ||
console.log('ok'); | ||
} | ||
process.on('exit', expect2Errors); | ||
setImmediate(function () { | ||
throw new Error(); | ||
}); | ||
process.removeAsyncListener(listeners[0]); | ||
process.removeAsyncListener(listeners[1]); |
@@ -28,7 +28,5 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
function onAsync() {} | ||
var results = []; | ||
var asyncNoHandleError = { | ||
error: function () { | ||
error: function(stor) { | ||
results.push(1); | ||
@@ -39,3 +37,3 @@ } | ||
var asyncHandleError = { | ||
error: function () { | ||
error: function(stor) { | ||
results.push(0); | ||
@@ -47,9 +45,21 @@ return true; | ||
var listeners = [ | ||
process.addAsyncListener(onAsync, asyncHandleError), | ||
process.addAsyncListener(onAsync, asyncNoHandleError) | ||
process.addAsyncListener(asyncHandleError), | ||
process.addAsyncListener(asyncNoHandleError) | ||
]; | ||
function expect2Errors() { | ||
// Even if an error handler returns true, both should fire. | ||
process.nextTick(function() { | ||
throw new Error(); | ||
}); | ||
// mixed handling of errors should propagate to all listeners | ||
process.removeAsyncListener(listeners[0]); | ||
process.removeAsyncListener(listeners[1]); | ||
process.on('exit', function(code) { | ||
// If the exit code isn't ok then return early to throw the stack that | ||
// caused the bad return code. | ||
if (code !== 0) | ||
return; | ||
// Mixed handling of errors should propagate to all listeners. | ||
assert.equal(results[0], 0); | ||
@@ -60,14 +70,2 @@ assert.equal(results[1], 1); | ||
console.log('ok'); | ||
} | ||
process.on('exit', expect2Errors); | ||
// error should be handled by both handlers | ||
// even if one handler returns 'true' | ||
setImmediate(function () { | ||
throw new Error(); | ||
}); | ||
process.removeAsyncListener(listeners[0]); | ||
process.removeAsyncListener(listeners[1]); |
@@ -24,3 +24,2 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
if (!process.addAsyncListener) require('../index.js'); | ||
if (!global.setImmediate) global.setImmediate = setTimeout; | ||
@@ -37,27 +36,47 @@ var assert = require('assert'); | ||
function onError(stor) { | ||
results.push(stor); | ||
} | ||
var results = []; | ||
var asyncNoHandleError = { | ||
error: function (stor) { | ||
results.push(stor); | ||
} | ||
var asyncNoHandleError0 = { | ||
create: onAsync0, | ||
error: onError | ||
}; | ||
var asyncNoHandleError1 = { | ||
create: onAsync1, | ||
error: onError | ||
}; | ||
process.addAsyncListener(onAsync0, asyncNoHandleError); | ||
process.addAsyncListener(onAsync1, asyncNoHandleError); | ||
var listeners = [ | ||
process.addAsyncListener(asyncNoHandleError0), | ||
process.addAsyncListener(asyncNoHandleError1) | ||
]; | ||
function expect2Errors() { | ||
var uncaughtFired = false; | ||
process.on('uncaughtException', function() { | ||
uncaughtFired = true; | ||
// unhandled errors should propagate to all listeners | ||
// Unhandled errors should propagate to all listeners. | ||
assert.equal(results[0], 0); | ||
assert.equal(results[1], 1); | ||
assert.equal(results.length, 2); | ||
}); | ||
console.log('ok'); | ||
} | ||
process.nextTick(function() { | ||
throw new Error(); | ||
}); | ||
process.on('uncaughtException', expect2Errors); | ||
process.on('exit', function(code) { | ||
// If the exit code isn't ok then return early to throw the stack that | ||
// caused the bad return code. | ||
if (code !== 0) | ||
return; | ||
setImmediate(function () { | ||
throw new Error(); | ||
// Need to remove the async listeners or tests will always pass | ||
for (var i = 0; i < listeners.length; i++) | ||
process.removeAsyncListener(listeners[i]); | ||
assert.ok(uncaughtFired); | ||
console.log('ok'); | ||
}); | ||
@@ -31,9 +31,16 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
var dgram = require('dgram'); | ||
var addListener = process.addAsyncListener; | ||
var removeListener = process.removeAsyncListener; | ||
var actualAsync = 0; | ||
var expectAsync = 0; | ||
var callbacks = { | ||
create: function onAsync() { | ||
actualAsync++; | ||
} | ||
}; | ||
var listener = process.createAsyncListener(callbacks); | ||
process.on('exit', function() { | ||
@@ -48,13 +55,2 @@ console.log('expected', expectAsync); | ||
// --- Begin Testing --- // | ||
function onAsync() { | ||
actualAsync++; | ||
} | ||
var listener = process.createAsyncListener(onAsync); | ||
var listener2 = process.createAsyncListener(onAsync); | ||
// Test listeners side-by-side | ||
@@ -137,3 +133,3 @@ process.nextTick(function() { | ||
addListener(listener); | ||
addListener(listener2); | ||
addListener(listener); | ||
@@ -147,3 +143,3 @@ setTimeout(function() { | ||
removeListener(listener); | ||
removeListener(listener2); | ||
removeListener(listener); | ||
}); | ||
@@ -200,4 +196,1 @@ | ||
}); | ||
// TODO(trevnorris): Test DNS, Zlib, etc. |
@@ -51,4 +51,4 @@ 'use strict'; | ||
process.addAsyncListener( | ||
function () { return cls.active; }, | ||
{ | ||
create : function () { return cls.active; }, | ||
before : function (context, domain) { cls.enter(domain); }, | ||
@@ -55,0 +55,0 @@ after : function (context, domain) { cls.exit(domain); }, |
@@ -11,10 +11,6 @@ var test = require('tap').test; | ||
var key = process.createAsyncListener( | ||
function () { return {}; }, | ||
{ | ||
after : function asyncAfter() { | ||
t.fail("after was called"); | ||
}, | ||
error : function asyncError(domain) { | ||
t.ok(domain, "got error"); | ||
} | ||
create : function () { return {}; }, | ||
after : function asyncAfter() { t.fail("after was called"); }, | ||
error : function asyncError(domain) { t.ok(domain, "got error"); } | ||
} | ||
@@ -21,0 +17,0 @@ ); |
@@ -97,6 +97,4 @@ var test = require('tap').test | ||
namespace.id = process.addAsyncListener( | ||
function () { | ||
return namespace.active; | ||
}, | ||
{ | ||
create : function () { return namespace.active; }, | ||
before : function (context, domain) { namespace.enter(domain); }, | ||
@@ -103,0 +101,0 @@ after : function (context, domain) { namespace.exit(domain); } |
@@ -16,5 +16,5 @@ var test = require('tap').test; | ||
var current; | ||
var id = process.addAsyncListener( | ||
function listener() { return counter++; }, | ||
process.addAsyncListener( | ||
{ | ||
create : function listener() { return counter++; }, | ||
before : function (_, domain) { current = domain; }, | ||
@@ -21,0 +21,0 @@ after : function () { current = null; } |
@@ -13,5 +13,5 @@ var test = require('tap').test; | ||
process.addAsyncListener( | ||
function () { return { val : ++cntr }; }, | ||
{ | ||
before : function (context, domain) { active = domain.val; }, | ||
create : function () { return { val : ++cntr }; }, | ||
before : function (context, data) { active = data.val; }, | ||
after : function () { active = null; } | ||
@@ -18,0 +18,0 @@ } |
@@ -32,4 +32,2 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
function asyncL() { } | ||
var callbacksObj = { | ||
@@ -56,3 +54,3 @@ error: function(domain, er) { | ||
var listener = process.createAsyncListener(asyncL, callbacksObj); | ||
var listener = process.createAsyncListener(callbacksObj); | ||
@@ -59,0 +57,0 @@ // Nested FS |
{ | ||
"name": "continuation-local-storage", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "userland implementation of https://github.com/joyent/node/issues/5243", | ||
@@ -43,8 +43,9 @@ "main": "context.js", | ||
"optionalDependencies": { | ||
"async-listener": "0.4.5" | ||
"async-listener": "0.4.7" | ||
}, | ||
"dependencies": { | ||
"emitter-listener": "1.0.1", | ||
"async-listener": "0.4.5" | ||
"async-listener": "0.4.7" | ||
}, | ||
"gitHead": "50892bd5f10388513db1df22ed5367a8321da9f3", | ||
"bugs": { | ||
@@ -54,9 +55,6 @@ "url": "https://github.com/othiym23/node-continuation-local-storage/issues" | ||
"homepage": "https://github.com/othiym23/node-continuation-local-storage", | ||
"_id": "continuation-local-storage@3.0.0", | ||
"dist": { | ||
"shasum": "ccd6dc389afaeeabe04b0794d651288969c4a5f7", | ||
"tarball": "http://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.0.0.tgz" | ||
}, | ||
"_from": "continuation-local-storage@^3.0.0", | ||
"_npmVersion": "1.3.14", | ||
"_id": "continuation-local-storage@3.1.0", | ||
"_shasum": "8f79fdf9486699f4253f090904086d621c9aa377", | ||
"_from": "continuation-local-storage@^3.1.0", | ||
"_npmVersion": "2.0.0-alpha-5", | ||
"_npmUser": { | ||
@@ -72,5 +70,8 @@ "name": "othiym23", | ||
], | ||
"_shasum": "ccd6dc389afaeeabe04b0794d651288969c4a5f7", | ||
"_resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.0.0.tgz", | ||
"dist": { | ||
"shasum": "8f79fdf9486699f4253f090904086d621c9aa377", | ||
"tarball": "http://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.1.0.tgz" | ||
}, | ||
"_resolved": "https://registry.npmjs.org/continuation-local-storage/-/continuation-local-storage-3.1.0.tgz", | ||
"readme": "ERROR: No README data found!" | ||
} |
@@ -17,5 +17,5 @@ 'use strict'; | ||
t.equal(blerg.message, "explicitly nonlocal exit", "got the expected exception"); | ||
t.notOk(namespace.get('outer'), "outer context should have been exited by throw"); | ||
t.ok(namespace.get('outer'), "outer context is still active"); | ||
t.notOk(namespace.get('inner'), "inner context should have been exited by throw"); | ||
t.equal(namespace._set.length, 0, "should be back to global state"); | ||
t.equal(namespace._set.length, 1, "should be back to outer state"); | ||
@@ -22,0 +22,0 @@ cls.destroyNamespace('test'); |
@@ -357,3 +357,7 @@ 'use strict'; | ||
t.equal(stats.mode.toString(8), '120777', "permissions should be as created"); | ||
t.equal( | ||
(stats.mode ^ process.umask()).toString(8), | ||
'120777', | ||
"permissions should be as created" | ||
); | ||
@@ -360,0 +364,0 @@ deleteLink(); |
{ | ||
"name": "newrelic", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"author": "New Relic Node.js agent team <nodejs@newrelic.com>", | ||
@@ -54,3 +54,3 @@ "licenses": [ | ||
"bunyan": "0.14.6", | ||
"continuation-local-storage": "^3.0.0", | ||
"continuation-local-storage": "^3.1.0", | ||
"yakaa": "^1.0.0" | ||
@@ -57,0 +57,0 @@ }, |
@@ -16,4 +16,4 @@ 'use strict'; | ||
, testDate | ||
, testTime | ||
, PORT | ||
, THRESHOLD | ||
; | ||
@@ -24,4 +24,4 @@ | ||
testDate = Date.now(); | ||
testTime = testDate - testVal; | ||
PORT = 0 | ||
PORT = 0; | ||
THRESHOLD = 200; | ||
}); | ||
@@ -33,4 +33,2 @@ | ||
var testVal = 1000; | ||
it("header should allow t=${time} style headers", function (done) { | ||
@@ -42,3 +40,3 @@ var server; | ||
assert(transTime > 0, 'must be positive'); | ||
assert(transTime < 2000, 'should have correct order'); | ||
assert(transTime < THRESHOLD, 'should be less than ' + THRESHOLD + 'ms (' + transTime + 'ms)'); | ||
response.end(); | ||
@@ -50,3 +48,3 @@ }); | ||
var opts = {host : 'localhost', port : port, headers: { | ||
"x-request-start": "t="+ testTime | ||
"x-request-start": "t="+ testDate | ||
} | ||
@@ -91,3 +89,3 @@ }; | ||
assert(transTime > 0, 'must be positive'); | ||
assert(transTime < 2000, 'should have correct order'); | ||
assert(transTime < THRESHOLD, 'should be less than ' + THRESHOLD + 'ms (' + transTime + 'ms)'); | ||
response.end(); | ||
@@ -99,3 +97,3 @@ }); | ||
var opts = {host : 'localhost', port : port, headers: { | ||
"x-request-start": testTime | ||
"x-request-start": testDate | ||
} | ||
@@ -117,3 +115,3 @@ }; | ||
assert(transTime > 0, 'must be positive'); | ||
assert(transTime < 2000, 'should have correct order'); | ||
assert(transTime < THRESHOLD, 'should be less than ' + THRESHOLD + 'ms (' + transTime + 'ms)'); | ||
response.end(); | ||
@@ -125,3 +123,3 @@ }); | ||
var opts = {host : 'localhost', port : port, headers: { | ||
"x-queue-start": testTime | ||
"x-queue-start": testDate | ||
} | ||
@@ -143,3 +141,3 @@ }; | ||
assert(transTime > 0, 'must be positive'); | ||
assert(transTime < 2000, 'should have correct order'); | ||
assert(transTime < THRESHOLD, 'should be less than ' + THRESHOLD + 'ms (' + transTime + 'ms)'); | ||
response.end(); | ||
@@ -151,3 +149,3 @@ }); | ||
var opts = {host : 'localhost', port : port, headers: { | ||
"x-request-start": testTime * 1e3 | ||
"x-request-start": testDate * 1e3 | ||
}}; | ||
@@ -168,3 +166,3 @@ http.get(opts, function () { | ||
assert(transTime > 0, 'must be positive'); | ||
assert(transTime < 2000, 'should have correct order'); | ||
assert(transTime < THRESHOLD, 'should be less than ' + THRESHOLD + 'ms (' + transTime + 'ms)'); | ||
response.end(); | ||
@@ -176,3 +174,3 @@ }); | ||
var opts = {host : 'localhost', port : port, headers: { | ||
"x-queue-start": testTime * 1e6 | ||
"x-queue-start": testDate * 1e6 | ||
}}; | ||
@@ -193,3 +191,3 @@ http.get(opts, function () { | ||
assert(transTime > 0, 'must be positive'); | ||
assert(transTime < 2000, 'should have correct order'); | ||
assert(transTime < THRESHOLD, 'should be less than ' + THRESHOLD + 'ms (' + transTime + 'ms)'); | ||
response.end(); | ||
@@ -201,3 +199,3 @@ }); | ||
var opts = {host : 'localhost', port : port, headers: { | ||
"x-request-start": testTime / 1e3 | ||
"x-request-start": testDate / 1e3 | ||
}}; | ||
@@ -204,0 +202,0 @@ http.get(opts, function () { |
@@ -8,3 +8,3 @@ 'use strict'; | ||
test("loading the application via index.js", function (t) { | ||
t.plan(4); | ||
t.plan(6); | ||
@@ -27,2 +27,4 @@ var agent; | ||
t.equal(agent._state, 'started', "agent didn't error connecting to staging"); | ||
t.deepEquals(agent.config.applications(), ['My Application'], "app name is valid") | ||
t.equals(agent.config.agent_enabled, true, "the agent is still enabled") | ||
agent.stop(function cb_stop() { | ||
@@ -35,2 +37,2 @@ t.equal(agent._state, 'stopped', "agent didn't error shutting down"); | ||
agent.once('started', shutdown); | ||
}); | ||
}); |
'use strict'; | ||
GLOBAL.NR_CASSANDRA = true | ||
var path = require('path') | ||
@@ -11,3 +9,2 @@ , tap = require('tap') | ||
, helper = require(path.join(__dirname, '..', 'lib', 'agent_helper')) | ||
, cassandra = require('node-cassandra-cql') | ||
; | ||
@@ -14,0 +11,0 @@ |
1962370
479
43261
495
96