... when rendering views, in this func in lib/view.js
function tryStat(path) {
debug('stat "%s"', path);
try {
return fs.statSync(path);
} catch (e) {
return undefined;
}
}
Correct, rendering the view will perform a sync operation. You should have caching of views turned on and then only the first hit is sync, and further hits to that view are no file system operations at all.
Unfortunately the views system was written in a way that cannot be converted to async without breaking everything, so it won't be completely async until Express 5.0. Using view caching in your production code will avoid this issue once each of your views have been hit once.
You can also find all this information, from using the trace sync flag to how to properly setup your Express application in production on the website: http://expressjs.com/en/advanced/best-practice-performance.html
@dougwilson thanks for the detailed reply!
Most helpful comment
Correct, rendering the view will perform a sync operation. You should have caching of views turned on and then only the first hit is sync, and further hits to that view are no file system operations at all.
Unfortunately the views system was written in a way that cannot be converted to async without breaking everything, so it won't be completely async until Express 5.0. Using view caching in your production code will avoid this issue once each of your views have been hit once.