3 ms·
> The problem with top-level await is that any modules depending on a module with a TLA cannot execute until it's done – the effects cascade and magnify through
by thomasfoster96 10y ago
> The problem with top-level await is that any modules depending on a module with a TLA cannot execute until it's done – the effects cascade and magnify throughout your app, rather than being confined to an explicitly async function.
Can't I already do this by putting a fs.readFileSync call or a synchronous AJAX call in my code?
- rich_harris 10y agoThe comparison to sync XHR is apt – put it this way, if you could go back in time and prevent synchronous XHR from being a thing, wouldn't you?
- thomasfoster96 10y agoYep, I probably would. However, the argument against allowing await in top level code doesn't make much sense if all of these bad side effects already exist.
- untog 10y agoThis would just increase the surface area of a bad side effect, though. Barely anyone uses sync XHR and the API is being phased out to the Fetch API - why would we encourage re-adding baggage like that?
- domenicd 10y agoSee elsewhere in this thread for why the comparison to sync XHR is very misleading.