Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: avoid throw in onerror for bad TLSSocket obj
TLSWrap.onerror has a helpful debug() call built in to it. However in case of a malformed TLSSocket object, where the `_tlsOptions` value is an unexpected `undefined`, accessing `_tlsOptions.isServer` causes a TypeError to be thrown. This commit ensures that the debug() call properly logs the state as 'unknown', instead of the two 'server' and 'client' choices previously available. Additionally, onerror branching is adjusted to allow such `undefined` options object, by use of optional chaining. Other methods are not being adjusted, as such a case of `undefined` options is not viable during regular processing of the TLSSocket. Fixes: #41501 PR-URL: #41523 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information