Skip to content

Commit

Permalink
Fix #1505
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed May 25, 2019
1 parent 420cf4e commit 12154ad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 52 deletions.
51 changes: 3 additions & 48 deletions src/async.js
Expand Up @@ -4,15 +4,13 @@ try {throw new Error(); } catch (e) {firstLineError = e;}
var ASSERT = require("./assert");
var schedule = require("./schedule");
var Queue = require("./queue");
var util = require("./util");

function Async() {
this._customScheduler = false;
this._isTickUsed = false;
this._lateQueue = new Queue(LATE_QUEUE_CAPACITY);
this._normalQueue = new Queue(NORMAL_QUEUE_CAPACITY);
this._haveDrainedQueues = false;
this._trampolineEnabled = true;
var self = this;
this.drainQueues = function () {
self._drainQueues();
Expand All @@ -31,16 +29,6 @@ Async.prototype.hasCustomScheduler = function() {
return this._customScheduler;
};

Async.prototype.enableTrampoline = function() {
this._trampolineEnabled = true;
};

Async.prototype.disableTrampolineIfNecessary = function() {
if (util.hasDevTools) {
this._trampolineEnabled = false;
}
};

Async.prototype.haveItemsQueued = function () {
return this._isTickUsed || this._haveDrainedQueues;
};
Expand Down Expand Up @@ -94,43 +82,10 @@ function AsyncSettlePromises(promise) {
this._queueTick();
}

if (!util.hasDevTools) {
Async.prototype.invokeLater = AsyncInvokeLater;
Async.prototype.invoke = AsyncInvoke;
Async.prototype.settlePromises = AsyncSettlePromises;
} else {
Async.prototype.invokeLater = function (fn, receiver, arg) {
if (this._trampolineEnabled) {
AsyncInvokeLater.call(this, fn, receiver, arg);
} else {
this._schedule(function() {
setTimeout(function() {
fn.call(receiver, arg);
}, 100);
});
}
};

Async.prototype.invoke = function (fn, receiver, arg) {
if (this._trampolineEnabled) {
AsyncInvoke.call(this, fn, receiver, arg);
} else {
this._schedule(function() {
fn.call(receiver, arg);
});
}
};
Async.prototype.invokeLater = AsyncInvokeLater;
Async.prototype.invoke = AsyncInvoke;
Async.prototype.settlePromises = AsyncSettlePromises;

Async.prototype.settlePromises = function(promise) {
if (this._trampolineEnabled) {
AsyncSettlePromises.call(this, promise);
} else {
this._schedule(function() {
promise._settlePromises();
});
}
};
}

function _drainQueue(queue) {
while (queue.length() > 0) {
Expand Down
2 changes: 0 additions & 2 deletions src/debuggability.js
Expand Up @@ -131,14 +131,12 @@ Promise.longStackTraces = function () {
Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
Promise.prototype._dereferenceTrace = Promise_dereferenceTrace;
Context.deactivateLongStackTraces();
async.enableTrampoline();
config.longStackTraces = false;
};
Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
Promise.prototype._dereferenceTrace = longStackTracesDereferenceTrace;
Context.activateLongStackTraces();
async.disableTrampolineIfNecessary();
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/util.js
Expand Up @@ -399,8 +399,6 @@ var ret = {
markAsOriginatingFromRejection: markAsOriginatingFromRejection,
classString: classString,
copyDescriptors: copyDescriptors,
hasDevTools: typeof chrome !== "undefined" && chrome &&
typeof chrome.loadTimes === "function",
isNode: isNode,
hasEnvVariables: hasEnvVariables,
env: env,
Expand Down

0 comments on commit 12154ad

Please sign in to comment.