domain-task
Advanced tools
Comparing version 1.0.0 to 1.0.1
15
main.js
@@ -11,5 +11,6 @@ var domain = require('domain'); | ||
// The application may have other listeners chained to this promise *after* | ||
// this listener. Since we don't want the combined task to complete until | ||
// all the handlers for child tasks have finished, delay the following by | ||
// one tick. | ||
// this listener, which may in turn register further tasks. Since we don't | ||
// want the combined task to complete until all the handlers for child tasks | ||
// have finished, delay the response to give time for more tasks to be added | ||
// synchronously. | ||
setTimeout(function () { | ||
@@ -19,3 +20,5 @@ state.numRemainingTasks--; | ||
state.hasIssuedSuccessCallback = true; | ||
state.completionCallback(/* error */ null); | ||
setTimeout(function () { | ||
state.completionCallback(/* error */ null); | ||
}, 0); | ||
} | ||
@@ -44,3 +47,5 @@ }, 0); | ||
state.hasIssuedSuccessCallback = true; | ||
state.completionCallback(/* error */ null); | ||
setTimeout(function () { | ||
state.completionCallback(/* error */ null); | ||
}, 0); | ||
} | ||
@@ -47,0 +52,0 @@ } |
{ | ||
"name": "domain-task", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tracks outstanding operations for a logical thread of execution", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
import * as url from 'url'; | ||
import * as domain from 'domain'; | ||
import * as domain from 'domain'; | ||
import * as domainContext from 'domain-context'; | ||
@@ -40,3 +40,3 @@ import { addTask } from './main'; | ||
} | ||
return isomorphicFetch(req, init); | ||
@@ -61,4 +61,4 @@ } | ||
} | ||
return domain.active ? domainContext.get(domainTaskStateKey) : noDomainBaseUrl; | ||
} |
@@ -12,5 +12,6 @@ import * as domain from 'domain'; | ||
// The application may have other listeners chained to this promise *after* | ||
// this listener. Since we don't want the combined task to complete until | ||
// all the handlers for child tasks have finished, delay the following by | ||
// one tick. | ||
// this listener, which may in turn register further tasks. Since we don't | ||
// want the combined task to complete until all the handlers for child tasks | ||
// have finished, delay the response to give time for more tasks to be added | ||
// synchronously. | ||
setTimeout(() => { | ||
@@ -20,3 +21,5 @@ state.numRemainingTasks--; | ||
state.hasIssuedSuccessCallback = true; | ||
state.completionCallback(/* error */ null); | ||
setTimeout(() => { | ||
state.completionCallback(/* error */ null); | ||
}, 0); | ||
} | ||
@@ -43,7 +46,9 @@ }, 0); | ||
synchronousResult = codeToRun(); | ||
// If no tasks were registered synchronously, then we're done already | ||
if (state.numRemainingTasks === 0 && !state.hasIssuedSuccessCallback) { | ||
state.hasIssuedSuccessCallback = true; | ||
state.completionCallback(/* error */ null); | ||
setTimeout(() => { | ||
state.completionCallback(/* error */ null); | ||
}, 0); | ||
} | ||
@@ -54,3 +59,3 @@ } catch(ex) { | ||
}); | ||
return synchronousResult; | ||
@@ -57,0 +62,0 @@ } |
12101
269