November 2013
Intermediate to advanced
148 pages
3h 12m
English
Given the cost that blocking has on the Node event loop, you might think it’s always bad to use synchronous file-access methods. To understand when it’s OK, you can think of Node programs as having two phases.
In the initialization phase, the program is getting set up, bringing in libraries, reading configuration parameters, and doing other mission-critical tasks. If something goes wrong at this early stage, not much can be done, and it’s best to fail fast. The only time you should consider synchronous file access is during the initialization phase of your program.
The second phase is the operation phase, when the program churns through the event loop. Since many Node programs are networked, this means accepting ...
Read now
Unlock full access