Re:Top-level await in JavaScript is a footgun
by domenicd on Wednesday September 14, 2016 @11:37AM
(#12498025)
Exactly correct. But note that
> your entry point would be unable to run anything while dependencies are awaiting
is very different from the situation with synchronous I/O (in a single-threaded environment).
With sync I/O, not only is your entry point unable to do anything (which is what it chose to do, by using `import` instead of `import()`), your entire app is unable to do anything! So other entry points are also blocked.
Even worse, since sync I/O blocks the event loop, it prevents the user from interacting with your web page or Node app---e.g. scrolling, clicking links, pressing Ctrl+C to exit, and so on.
> your entry point would be unable to run anything while dependencies are awaiting
is very different from the situation with synchronous I/O (in a single-threaded environment).
With sync I/O, not only is your entry point unable to do anything (which is what it chose to do, by using `import` instead of `import()`), your entire app is unable to do anything! So other entry points are also blocked.
Even worse, since sync I/O blocks the event loop, it prevents the user from interacting with your web page or Node app---e.g. scrolling, clicking links, pressing Ctrl+C to exit, and so on.