Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on V8 adds support for top-level await. Parent comment
> All this async code without decent locking primitives is leading to a rabbit hole of race conditions...
No, it's not. Here's a lock:
let lock = Promise.resolve() // ... lock = lock.then(() => { /* critical section */ })
[0] https://caolan.github.io/async/v3/docs.html
[1] https://github.com/sindresorhus/p-queue
There are no comments on this comment yet.
> All this async code without decent locking primitives is leading to a rabbit hole of race conditions...
No, it's not. Here's a lock:
For the rare instances where more complex async flow control is required, there are a bunch of libraries for that (e.g. async[0], p-queue[1], etc.).[0] https://caolan.github.io/async/v3/docs.html
[1] https://github.com/sindresorhus/p-queue