4 ms·
More specifically, any functions that end in Sync should be avoided. Unfortunately a lot of people think that these functions are a simple way to "not have to
by joepie91_ 11y ago
More specifically, any functions that end in Sync should be avoided.
Unfortunately a lot of people think that these functions are a simple way to "not have to deal with callbacks", which is not correct...
- Zarel 11y agoIt's not correct? Is there any reason not to use the Sync functions if you're not writing a web server and don't particularly care for performance?
- joepie91_ 11y agoIt is indeed not correct. They are not functionally equivalent to their asynchronous equivalents at all - your entire event loop will be blocked for the full duration of the operation. This may sound like "not a big deal", but even an operation that takes 1ms will cause noticeable lag at ~50 operations per second, and block everything approaching a thousand. For emphasis: they block the entire event loop. Not a single request, not a single client, not a single operation or event. The entire application for every user everywhere.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- swang 11y agoIf it's your own thing, do whatever you want. But the only thing sync should be used is to exec shell scripts in node.js. sync functions are bad otherwise in any kind of production environment.