How protect critical section in node

Node-red runs on node.js which is single threaded. It has an event loop which you can read about here

These copy+paste quotes do some justice to briefly explain what's going on...

The way it operates and queues the event loop via callbacks can give the illusion of multi-threading but at it's core only one bit of the code written by the developer is being executed at a time.

And...

The programming model in Node.js is a single threaded event loop with access to asynchronous operations that use native code to implement asynchronous behavior for some operations (disk I/O, networking, timers, some crypto operations, etc...)