tls: handle `error` events with `_tlsError`
Checklist
-
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
tls
Description of change
Previously TLSSocket#_emitTLSError
was used as an error
event
handler. However that function can emit error
event itself, so it is
not suitable for such use. Luckily the event can be emitted only when
the control is released, so this looping-error can't happen.
Replace the error handler for clarity and correctness.
cc @nodejs/crypto