Status Update
Comments
mi...@google.com <mi...@google.com> #2
Hello,
Thank you for creating this issue.
This behaviour was already reported internally. You can click the star on the top left in this page if you want to keep track of this.
Kind regards.
sp...@easton-consulting.com <sp...@easton-consulting.com> #3
TLDR:
A pure asynchronous workload is magnitudes faster then a synchronous one. I verified the code against Node v12.14.1 and got similar timings.
The part I don't understand yet is when you mix synchronous and asynchronous code. The async workload seems to get locked with the sync work load. I got the same thing in Node.
The Big Issue:
promises is being processed serially when you add an Apps Script service ie SpreadsheetApp. It's like there is a separate stack for Apps Script service calls. When ever a call to a service happens, it gets added to the stack and then it is processed serially. So Promise.all just adds the call to the stack faster then adding is serially. No real time savings. It only makes sense if your Promise.all is doing something computationally expensive in addition to the Apps Script service call.
kt...@factset.com <kt...@factset.com> #4
sj...@teraneuro.com <sj...@teraneuro.com> #5
Do we have any status update on this?
da...@gmail.com <da...@gmail.com> #6
+1 It makes no sense V8 supports async function definition format but there is no real implementation behind that.
[Deleted User] <[Deleted User]> #7
mp...@expertease.ca <mp...@expertease.ca> #8
ps...@gmail.com <ps...@gmail.com> #9
[Deleted User] <[Deleted User]> #10
sm...@gmail.com <sm...@gmail.com> #11
rm...@google.com <rm...@google.com> #12
The internal discussions so far have borne out our concern that true async operation is something that would confuse many casual Apps Script users. async can be hard to debug and understand, and requires the developer to be familiar async behavior (callbacks) and if I/O calls to dependencies are also async.
These limitations can be worked around by using:
var trigger = ScriptApp.newTrigger("myFunction").timeBased().after(30 * 1000).create();
(limited to 90mins execution time per day currently) and use an external data store (such as a Google Sheet) or Script Properties.https://github.com/tanaikech/RunAll (usesfetchAll()
in one function to trigger other executions via adoGet()
to the same or another funciton)
These methods allow developers who understand async ops (and state management) to intentionally gain access to that powerful functionality, without causing a majority of users to encounter behavior that they think is incorrect. That negative experience would likely drive users away and otherwise harm adoption and usage of Apps Script.
Having said that, we should call this out in our public docs to avoid people spending time refactoring code as mentioned in
mw...@gmail.com <mw...@gmail.com> #13
How are these approaches less confusing? This is mind boggling. Document scripting is supposed to be easy but almost every weird quirk of Apps Script makes things harder than "normal" programming.
BTW Async debugging is certainly possible and easy as shown in Chrome Dev Tools. Perhaps improving tooling rather than restricting features would be more beneficial?
mw...@gmail.com <mw...@gmail.com> #14
Also even if restricting features ends up the solution you must do better job. I don't think improving documentation is enough - show warnings/errors in editor for unsupported code.
[Deleted User] <[Deleted User]> #15
Ti...@rogersgrain.com <Ti...@rogersgrain.com> #16
mp...@expertease.ca <mp...@expertease.ca> #17
The assumption that the majority of users would be confused by async working like async, sounds extremely condescending...
Maybe google team could explain a little further their thoughts regarding this.
ni...@gmail.com <ni...@gmail.com> #18
So, because you think that async is too difficult for casual Apps Script users, you have decided to actively:
- Gimp the language.
- Divert from the Ecmascript Language Specification.
- Split the eco-system and make trouble-shooting harder for those who expect Javascript features to work like they are supposed to.
- Ensure that many Google Workspace Marketplace apps are slower than necessary and that both developers and end-users of them have a less than stellar experience.
... Please reconsider.
an...@gmail.com <an...@gmail.com> #19
I was bothered initially when I tried using Promise objects and discovered they were actually synchronous. Later I learned that the synchronous behavior is only on the server side. I'm fine with that. I believe javascript was originally created to run on the browser not on a server.
ch...@amplifiedit.cdw.com <ch...@amplifiedit.cdw.com> #21
I would much prefer standards-compliant Javascript execution to be the default behavior, but hiding it behind a flag would be better than the current state.
xa...@gmail.com <xa...@gmail.com> #22
rm...@google.com <rm...@google.com> #23
We certainly are not slighting developers implying that people wouldn't understand. We use Apps Script extensively within Google. Apps Script has not had concurrency since the inception. The addition of keywords to conform to the language spec didn't change the behavior of Apps Script as it was implemented/used. As such this is a Feature Request to implement true async in Apps Script.
Perhaps a warning on the keyword usage is an option.
Developers "in the know" can already get around this using timers and google.script.run
, and that is our suggested workaround (as it already was, like in
At this point I do not have an estimate of when that work could commence.
[Deleted User] <[Deleted User]> #24
Do language specifications not include what keywords do? I dunno... seems pointless to add keywords that don't change the functionality...
> Perhaps a warning on the keyword usage is an option.
Yes, please. This would have helped avoided the issue over a year ago where I wasted a bunch of time trying to use async to you know... make asynchronous calls. At least I with a warning, I would have found out the most straightforward approach won't work.
Not that I have any stake in this anymore. My company moved off Apps Script and I discourage its use in future projects 😅
j....@i-t-c.fr <j....@i-t-c.fr> #25
[Deleted User] <[Deleted User]> #26
[Deleted User] <[Deleted User]> #27
Also, after you find a new assignee, consider changing this to a bug instead of a "feature request." We don't want a new feature we want the async feature to do what it says on the tin: be asynchronous.
(Fs in the chat for any P3s which likely get even less attention than this bug =P)
is...@google.com <is...@google.com>
jp...@google.com <jp...@google.com>
da...@gmail.com <da...@gmail.com> #28
ja...@pwc.com <ja...@pwc.com> #29
Will the Apps Script methods like DriveApp, SpreadsheetsApp and others need to be updated to support async?
[Deleted User] <[Deleted User]> #30
jp...@google.com <jp...@google.com> #31
async/await do function as expected, the issue is that the underlying tasks in Apps Script are synchronous/blocking and thus the task queue is still synchronous.
mp...@expertease.ca <mp...@expertease.ca> #32
someone proposed this in this thread. has this been taken into consideration?
Perhaps a warning on the keyword usage is an option.
Yes, please. This would have helped avoided the issue over a year ago where I wasted a bunch of time trying to use async to you know... make asynchronous calls. At least I with a warning, I would have found out the most straightforward approach won't work.
jp...@google.com <jp...@google.com> #33
mp...@expertease.ca <mp...@expertease.ca> #34
interesting thank you
Description
The V8 runtime is not asynchronous. Research is here:
Basically, setTimeout is not defined, promises follows the syntax but does not work concurrently, which we can tell by the timing.
What is the expected output? What do you see instead? If you see error messages, please provide them.
The documentation indicates function declarations that include async, but it's not async. This probably needs to be highlighted somehow.