A series of examples illustrating race conditions in Node.js and potential solutions.
Check out the code in the examples
folder.
examples/race-dummy.js
: explores a simple race condition.examples/race-simple-fix.js
: provides a simple solution usingasync/await
.examples/race-mutex.js
: provides a solution using mutexes (using the libraryasync-mutex
).examples/race-mutex-no-lib.js
: provides a solution using mutexes (implementing the mutex pattern by ourselves).
These examples are illustrated in the article: Node.js race conditions.