diff --git a/src/engine/execute.js b/src/engine/execute.js index 6017ac46c..762df5b9e 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -113,14 +113,6 @@ const RECURSIVE = true; */ const execute = function (sequencer, thread, recursiveCall) { const runtime = sequencer.runtime; - const target = thread.target; - - // Stop if block or target no longer exists. - if (target === null) { - // No block found: stop the thread; script no longer exists. - sequencer.retireThread(thread); - return; - } // Current block to execute is the one on the top of the stack. const currentBlockId = thread.peekStack(); diff --git a/src/engine/sequencer.js b/src/engine/sequencer.js index 2db1c6ed8..6a8c3dd6d 100644 --- a/src/engine/sequencer.js +++ b/src/engine/sequencer.js @@ -197,7 +197,11 @@ class Sequencer { this.runtime.profiler.records.push( this.runtime.profiler.START, executeProfilerId, null, performance.now()); } - execute(this, thread); + if (thread.target === null) { + this.retireThread(thread); + } else { + execute(this, thread); + } if (this.runtime.profiler !== null) { // this.runtime.profiler.stop(); this.runtime.profiler.records.push(this.runtime.profiler.STOP, performance.now());