_hyperscript
_hyperscript copied to clipboard
[Bug] asynchronous JavaScript code causes _hyperscript to throw an error
The following code
init
log 'before asynchrously succeeding JavaScript'
js
return new Promise((resolve,reject) => {
setTimeout(resolve,2000)
})
end
log 'after asynchrously succeeding JavaScript'
log 'before asynchrously failing JavaScript'
js
return new Promise((resolve,reject) => {
setTimeout(reject,2000)
})
end
log 'after asynchrously failing JavaScript'
end
fails with the following error
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'args')
at o.unifiedEval (hyperscript.org:1:15452)
at o.unifiedExec (hyperscript.org:1:14547)
at hyperscript.org:1:14995
before it reaches the second log statement (the one that should write after asynchrously succeeding JavaScript)
A live example can be found here
Note: the exception is thrown in line 1575 of the uncompressed code. It crashes because the command passed to unifiedExec is undefined. It was called from line 1553, where resolvedNext is undefined.
Note: asynchronous JS functions defined within a JS "feature" work as intended (see this example)