<@UJ2V6V8KD> - I saw your NetSuite Now On Air demo...
# suitescript
m
@Ashwin K. - I saw your NetSuite Now On Air demo for server side promises which looks very promising lol and was hoping you could clarify something. If there are unresolved promises when the script reaches the end of the entry point function, will those continue to run asynchronously after the suitelet/user event has returned control, or will it block until they are complete?
w
From my tests with this, when calling a test Suitelet that has some longer running async function (1min), it looks like browser won't receive a response until all functions are completed. But I'd love to hear a clearification from @Ashwin K..
m
@Watz from what I understood actual async promises server side is not released yet. I.e. you can already use promises server side but they will still run synchronously.
w
Ok, I was just looking at the logging done by the script and saw that a log that was right before the script ended was logged before anything from the async function.
a
@michoel lol... nice word play there 🙂 thanks for taking the time to watch my presentation! When this is released, the runtime would wait for all unresolved promises to resolve before ending the script execution. @Watz the async server-side promises is not yet released. It is supported syntactically only and would behave synchronously if used today.
w
@Ashwin K. could you explain why the final log of the script is logged before the logs inside the async function?
function onRequest(scriptContext){
log.audit('START OF onRequest');
mainAsyncExecution().then(function (result) {
log.audit('complete script','result', JSON.stringify(result));
})
.catch(function (e) {
log.error("e", e);
log.error("e.stack", e.stack);
});
log.audit('END OF MAIN onRequest');
}
return {onRequest: onRequest};