Skip to main content
Version: v0.0.3

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, EACCESpermanent (false)
  • ECONNREFUSED, ECONNRESET, ETIMEDOUT, EHOSTUNREACH, ENETUNREACH, EPIPEtransient (true)
  • CERT_* and UNABLE_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 a clientAuth: 'MUST' server rejecting the client certificate recurs on every attempt. On TLS-configured connections MllpClient additionally consults isTlsProtocolError, which also catches EPROTO/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 with connectionCause: 'framing-fatal') → permanent (false). The peer is not speaking MLLP, an HTTP probe, a health check, a wrong-port misconfiguration, or is emitting frames past maxFrameSizeBytes. 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 by retryStrategy and 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');
}
});