You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consthandlePromise=(primitiveReportedValue,sequencer,thread,blockCached,lastOperation)=>{if(thread.status===Thread.STATUS_RUNNING){// Primitive returned a promise; automatically yield thread.thread.status=Thread.STATUS_PROMISE_WAIT;// NOTE: Status is configured **before** registering promise handlers.}// Promise handlersprimitiveReportedValue.then(resolvedValue=>{// ...},rejectionReason=>{// ...});};
Actual Behavior
in src/compiler/jsexecute.js::isPromise, L131
constisPromise=value=>(// see engine/execute.jsvalue!==null&&typeofvalue==='object'&&typeofvalue.then==='function');// NOTE: value.catch is not detected. It should not be used either.
in src/compiler/jsexecute.js::waitPromise, L108
constwaitPromise=function*(promise){constthread=globalState.thread;letreturnValue;promise.then(value=>{returnValue=value;thread.status=0;// STATUS_RUNNING}).catch(error=>{thread.status=0;// STATUS_RUNNINGglobalState.log.warn('Promise rejected in compiled script:',error);});// NOTE: `catch` might be `undefined`.// enter STATUS_PROMISE_WAIT and yield// this will stop script execution until the promise handlers reset the thread statusthread.status=1;// STATUS_PROMISE_WAIT // NOTE: if promise handlers executed immediately, enter STATUS_PROMISE_WAIT here will cause soft-lock.yield;returnreturnValue;};
Steps to Reproduce
in exploitExtension.js
(function(Scratch){if(!Scratch.extensions.unsandboxed)thrownewError('Load this extension as unsandboxed extension');classExtension{getInfo(){return{id: 'exploit',name: 'Exploit',color1: '#000000',blocks: [{opcode: 'hack',blockType: Scratch.BlockType.COMMAND,text: 'Exploit'}]};}hack(){// returns a PromiseLike that calls handler immediately.constpm={then(callbackFn){callbackFn();returnpm;},catch(){returnpm;}};returnpm;}};Scratch.extensions.register(newExtension());})(Scratch);
Operating System and Browser
N/A
The text was updated successfully, but these errors were encountered:
Expected Behavior
Actual Behavior
Steps to Reproduce
Operating System and Browser
N/A
The text was updated successfully, but these errors were encountered: