By listening for the error event on the stream instances.
error
Additionally, you can use try-catch blocks when working with streams to catch synchronous errors.