Function: isTransientConnectionError()
isTransientConnectionError(
err):boolean
Classifies a connection error as transient (eligible for auto-reconnect) or permanent (halts auto-reconnect, transitions to CLOSED).
Used internally by MllpClient BEFORE invoking retryStrategy
(see RetryContext.classifiedAs). Re-exported so callers can implement
their own retry policies.
Classification table:
ENOTFOUND,EACCES→ permanent (false)ECONNREFUSED,ECONNRESET,ETIMEDOUT,EHOSTUNREACH,ENETUNREACH,EPIPE→ transient (true)CERT_*andUNABLE_TO_VERIFY_LEAF_SIGNATURE/DEPTH_ZERO_SELF_SIGNED_CERT/SELF_SIGNED_CERT_IN_CHAIN(any isTlsVerificationErrorCode code) → permanent (false), never auto-reconnect-loop into a misconfigured or MITM'd endpoint.ERR_SSL_*(Node TLS alert codes) → permanent (false), a TLS protocol failure such as aclientAuth: 'MUST'server rejecting the client certificate recurs on every attempt. On TLS-configured connectionsMllpClientadditionally consults isTlsProtocolError, which also catchesEPROTO/alert-bearing OpenSSL errors that this generic classifier (which cannot know the connection was TLS) leaves transient.MLLP_*(any MllpFramingError code, a fatal decoder throw, surfaced withconnectionCause: 'framing-fatal') → permanent (false). The peer is not speaking MLLP, an HTTP probe, a health check, a wrong-port misconfiguration, or is emitting frames pastmaxFrameSizeBytes. Every reconnect meets the same bytes, so retrying is an unbounded storm against a peer that is already misconfigured. If a peer's quirk is expected, the decoder's tolerance opt-ins are the supported answer, they make it a warning, not a fatal.- non-Error / unknown / no-code → transient (
true), Postel's Law default. Reconnect attempts are bounded byretryStrategyand the 30s backoff cap, so the default is safe.
Parameters
err
unknown
Returns
boolean
Example
import { isTransientConnectionError } from '@cosyte/mllp';
client.on('error', (err) => {
if (isTransientConnectionError(err)) {
metrics.increment('mllp.transient_error');
} else {
metrics.increment('mllp.permanent_error');
}
});