Skip to content

Commit

Permalink
Bind the step function to the active domain (if present)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehcode committed May 4, 2015
1 parent 878d1f3 commit 10f36d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@
runtime.async = function(innerFn, outerFn, self, tryLocsList) {
return new Promise(function(resolve, reject) {
var generator = wrap(innerFn, outerFn, self, tryLocsList);
var callNext = step.bind(generator, "next");
var callThrow = step.bind(generator, "throw");

function step(method, arg) {
var step = function(method, arg) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
reject(record.arg);
Expand All @@ -121,8 +119,15 @@
} else {
Promise.resolve(info.value).then(callNext, callThrow);
}
};

if (process.domain) {
step = process.domain.bind(step);

This comment has been minimized.

Copy link
@Andarist

Andarist Jul 21, 2017

Contributor

@mehcode what was the purpose of this? im literally curious :)

}

var callNext = step.bind(generator, "next");
var callThrow = step.bind(generator, "throw");

callNext();
});
};
Expand Down

0 comments on commit 10f36d7

Please sign in to comment.