mongodb-memory-server icon indicating copy to clipboard operation
mongodb-memory-server copied to clipboard

Silence `ECONNRESET` on `stop`

Open hasezoey opened this issue 1 year ago • 1 comments

It seems like on .stop after the shutdown command it may be possible that a ECONNRESET Error happens instead of the connection being closed, similar to the already ignored connection 1 to 127.0.0.1:41485 closed message pre mongodb 4.2.

This has been originally reported on discord, where the user notes that this might only happen on replset members, but not single instances.

Example Error:

Error: read ECONNRESET
        at TCP.onStreamRead (node:internal/stream_base_commons:216:20) {
      errno: -4077,
      code: 'ECONNRESET',
      syscall: 'read'
    }

      at node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:469:23
      at MongoMemoryServer.stop (node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:593:5)
          at async Promise.all (index 0)
      at MongoMemoryReplSet.stop (node_modules/mongodb-memory-server-core/src/MongoMemoryReplSet.ts:546:33)

(MMS 10.1.2, binary 7.0.14, windows)

hasezoey avatar Nov 19 '24 12:11 hasezoey

The same issue happens for me as well (MMS 10.1.3, binary 7.0.14, Windows)

Error: read ECONNRESET
        at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
      errno: -4077,
      code: 'ECONNRESET',
      syscall: 'read'
    }

at node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:469:23
      at MongoMemoryServer.stop (node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:593:5)
          at async Promise.all (index 0)
      at MongoMemoryReplSet.stop (node_modules/mongodb-memory-server-core/src/MongoMemoryReplSet.ts:546:33)

nichiporenko avatar Feb 10 '25 13:02 nichiporenko

The same issue happens for me as well (MMS 10.1.4, Windows 11)

    at Connection.onSocketError (C:\_works\xxxxx\node_modules\mongodb\src\cmap\connection.ts:308:18)
    at Socket.emit (node:events:530:35)
    at Socket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errorLabelSet: Set(0) {},
  beforeHandshake: false,
  [cause]: Error: read ECONNRESET
      at TCP.onStreamRead (node:internal/stream_base_commons:216:20) {
    errno: -4077,
    code: 'ECONNRESET',
    syscall: 'read'
  }
}

Solarisbf avatar Jul 03 '25 08:07 Solarisbf

:tada: This issue has been resolved in version 10.3.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Oct 29 '25 13:10 github-actions[bot]