• Public
  • Public/Protected
  • All

Class MongoUnexpectedServerResponseError

An error generated when a parsable unexpected response comes from the server. This is generally an error where the driver in a state expecting a certain behavior to occur in the next message from MongoDB but it receives something else. This error does not represent an issue with wire message formatting.


When an operation fails, it is the driver's job to retry it. It must perform serverSelection again to make sure that it attempts the operation against a server in a good state. If server selection returns a server that does not support retryable operations, this error is used. This scenario is unlikely as retryable support would also have been determined on the first attempt but it is possible the state change could report a selectable server that does not support retries.





code?: string | number

This is a number in MongoServerError and a string in MongoDriverError


Define the type override on the subclasses when we can use the override keyword

message: string
stack?: string
topologyVersion?: TopologyVersion
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Type declaration

stackTraceLimit: number


  • get errmsg(): string
  • Legacy name for server error responses

    Returns string

  • get errorLabels(): string[]
  • Returns string[]

  • get name(): string


  • addErrorLabel(label: string): void
  • hasErrorLabel(label: string): boolean
  • Checks the error to see if it has an error label


    • label: string

      The error label to check for

    Returns boolean

    returns true if the error has the provided error label

  • captureStackTrace(targetObject: object, constructorOpt?: Function): void
  • Create .stack property on a target object


    • targetObject: object
    • Optional constructorOpt: Function

    Returns void

Generated using TypeDoc