async-listener
Advanced tools
Comparing version 0.4.4 to 0.4.5
62
glue.js
@@ -206,9 +206,2 @@ var wrap = require('shimmer').wrap; | ||
/** | ||
* The error handler in the error-checker for old Node must rethrow to give | ||
* domains and other uncaughtException handlers a chance to fire, but there's | ||
* nothing for the uncaughtException handler to do. | ||
*/ | ||
var threw = false; | ||
/** | ||
* If an error handler in asyncWrap throws, the process must die. Under 0.8 | ||
@@ -227,7 +220,2 @@ * and earlier the only way to put a bullet through the head of the process | ||
asyncCatcher = function uncaughtCatcher(er) { | ||
if (threw) { | ||
threw = false; | ||
return; | ||
} | ||
// going down hard | ||
@@ -278,2 +266,10 @@ if (errorThrew) throw er; | ||
return function () { | ||
/*jshint maxdepth:4*/ | ||
// after() handlers don't run if threw | ||
var threw = false; | ||
// ...unless the error is handled | ||
var handled = false; | ||
/* More than one listener can end up inside these closures, so save the | ||
@@ -305,3 +301,3 @@ * current listeners on a stack. | ||
catch (er) { | ||
var handled = false; | ||
threw = true; | ||
for (var i = 0; i < length; ++i) { | ||
@@ -320,23 +316,29 @@ var error = listeners[i].callbacks.error; | ||
// back to the previous listener list on the stack | ||
listeners = listenerStack.pop(); | ||
if (!handled) { | ||
// having an uncaughtException handler here alters crash semantics | ||
process.removeListener('uncaughtException', asyncCatcher); | ||
process._originalNextTick(function () { | ||
process.addListener('uncaughtException', asyncCatcher); | ||
}); | ||
if (handled) return; | ||
threw = true; | ||
throw er; | ||
throw er; | ||
} | ||
} | ||
finally { | ||
/* | ||
* after handlers (not run if original throws) | ||
*/ | ||
if (!threw || handled) { | ||
inAsyncTick = true; | ||
for (i = 0; i < length; ++i) { | ||
var after = list[i].callbacks && list[i].callbacks.after; | ||
if (typeof after === 'function') after(this, values[i], returned); | ||
} | ||
inAsyncTick = false; | ||
} | ||
/* | ||
* after handlers (not run if original throws) | ||
*/ | ||
inAsyncTick = true; | ||
for (i = 0; i < length; ++i) { | ||
var after = list[i].callbacks && list[i].callbacks.after; | ||
if (typeof after === 'function') after(this, values[i], returned); | ||
// back to the previous listener list on the stack | ||
listeners = listenerStack.pop(); | ||
} | ||
inAsyncTick = false; | ||
// back to the previous listener list on the stack | ||
listeners = listenerStack.pop(); | ||
@@ -348,3 +350,3 @@ return returned; | ||
// will be the first to fire if async-listener is the first module loaded | ||
process.on('uncaughtException', asyncCatcher); | ||
process.addListener('uncaughtException', asyncCatcher); | ||
} | ||
@@ -351,0 +353,0 @@ |
@@ -90,2 +90,7 @@ 'use strict'; | ||
// need unwrapped nextTick for use within < 0.9 async error handling | ||
if (!process._fatalException) { | ||
process._originalNextTick = process.nextTick; | ||
} | ||
var processors = ['nextTick']; | ||
@@ -92,0 +97,0 @@ if (process._nextDomainTick) processors.push('_nextDomainTick'); |
{ | ||
"name": "async-listener", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "Polyfill exporting trevnorris's 0.11+ asyncListener API.", | ||
@@ -33,3 +33,3 @@ "author": "Forrest L Norvell <ogd@aoaioxxysz.net>", | ||
"dependencies": { | ||
"shimmer": "~1" | ||
"shimmer": "1.0.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
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
72666
2110
+ Addedshimmer@1.0.0(transitive)
- Removedshimmer@1.2.1(transitive)
Updatedshimmer@1.0.0