Skip to content

Commit

Permalink
Fix async hooks in earlier version of v8.x
Browse files Browse the repository at this point in the history
Fixes #366
  • Loading branch information
laverdet committed Mar 21, 2018
1 parent ae2dd09 commit fd6fbc6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions fibers.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,29 @@ function setupAsyncHacks(Fiber) {
throw new Error('Push/pop do not exist');
}

var kExecutionAsyncId = aw.constants.kExecutionAsyncId;
var kTriggerAsyncId = aw.constants.kTriggerAsyncId;
var kExecutionAsyncId;
if (aw.constants.kExecutionAsyncId === undefined) {
kExecutionAsyncId = aw.constants.kCurrentAsyncId;
} else {
kExecutionAsyncId = aw.constants.kExecutionAsyncId;
}
var kTriggerAsyncId;
if (aw.constants.kTriggerAsyncId === undefined) {
kTriggerAsyncId = aw.constants.kCurrentTriggerId;
} else {
kTriggerAsyncId = aw.constants.kTriggerAsyncId;
}

var asyncIds = aw.async_id_fields || aw.async_uid_fields;

function getAndClearStack() {
var ii = getAsyncIdStackSize();
var stack = new Array(ii);
for (; ii > 0; --ii) {
var asyncId = aw.async_id_fields[kExecutionAsyncId];
var asyncId = asyncIds[kExecutionAsyncId];
stack[ii - 1] = {
asyncId: asyncId,
triggerId: aw.async_id_fields[kTriggerAsyncId],
triggerId: asyncIds[kTriggerAsyncId],
};
aw.popAsyncIds(asyncId);
}
Expand Down

0 comments on commit fd6fbc6

Please sign in to comment.