mongodb-memory-server fails to stop on windows when a process is terminated with Control C

Created on 24 Oct 2020  Â·  4Comments  Â·  Source: nodkz/mongodb-memory-server

Versions

  • NodeJS: v12.17.0
  • mongodb-memory-server-*: 6.9.2
  • mongodb: 3.6.2
  • mongoose: 5.10.9
  • system: windows 10

package: mongo-memory-server

What is the Problem?


When a process is terminated with Ctrl+C on windows, mongod exits with CODE: 12, but mongodb-memory-server treats it as an error.

MongodbInstance: Instance has failed: Mongod instance closed with code "12"

Terminal output

i [mocha] waiting for changes...
  MongoMS:MongoInstance Mongo[63869]: STDOUT: 2020-10-24T21:48:56.821+0200 I CONTROL  [thread9] Ctrl-C signal
  MongoMS:MongoInstance 2020-10-24T21:48:56.821+0200 I CONTROL  [consoleTerminate] got CTRL_C_EVENT, will terminate after current cmd ends
  MongoMS:MongoInstance  +8s
‼ [mocha] cleaning up, please wait...
Terminate batch job (Y/N)?   MongoMS:MongoInstance Mongo[63869]: [MongoKiller]: exit - [0,null] +19ms
  MongoMS:MongoInstance Mongo[63869]: STDOUT: 2020-10-24T21:48:56.822+0200 I NETWORK  [consoleTerminate] shutdown: going to close listening sockets...
  MongoMS:MongoInstance 2020-10-24T21:48:56.822+0200 I CONTROL  [consoleTerminate] Shutting down free monitoring
  MongoMS:MongoInstance 2020-10-24T21:48:56.822+0200 I FTDC     [consoleTerminate] Shutting down full-time diagnostic data capture
  MongoMS:MongoInstance 2020-10-24T21:48:56.831+0200 I STORAGE  [consoleTerminate] shutdown: removing fs lock...
  MongoMS:MongoInstance 2020-10-24T21:48:56.832+0200 I CONTROL  [consoleTerminate] now exiting
  MongoMS:MongoInstance 2020-10-24T21:48:56.832+0200 I CONTROL  [consoleTerminate] shutting down with code:12
  MongoMS:MongoInstance  +3ms
  MongoMS:MongoMemoryServer Called MongoMemoryServer.stop() method +12s
  MongoMS:MongoMemoryServer Called MongoMemoryServer.ensureInstance() method +3ms
  MongoMS:MongoMemoryServer Shutdown MongoDB server on port 63869 with pid 18892 +3ms
  MongoMS:MongoInstance Mongo[63869]: Called MongoInstance.kill(): +15ms
  MongoMS:MongoInstance Mongo[63869]: - childProcess: send "SIGINT" +2ms
  MongoMS:MongoInstance Mongo[63869]: - childProcess: got exit signal, Code: 12, Signal: null +1ms
  MongoMS:MongoInstance Mongo[63869]: - killerProcess: send "SIGINT" +1ms
  MongoMS:MongoInstance Mongo[63869]: Mongod instance closed with an non-0 code! +1ms
  MongoMS:MongoInstance Mongo[63869]: CLOSE: 12 +1ms
  MongoMS:MongoInstance Mongo[63869]: MongodbInstance: Instance has failed: Mongod instance closed with code "12" +1ms
  MongoMS:MongoInstance Mongo[63869]: kill_internal timeout triggered, trying SIGKILL +10s
  MongoMS:MongoInstance Mongo[63869]: kill_internal timeout triggered again, rejecting +10s
Error: Process didnt exit, enable debug for more information.
    at Timeout._onTimeout (D:\projects\ope\service-upload\node_modules\mongodb-memory-server-core\src\util\MongoInstance.ts:170:20)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

Do you know why it happenes?

missing special handling for the CODE 12?

https://docs.mongodb.com/manual/reference/exit-codes/#12

Returned by the mongod.exe process on Windows when it receives a Control-C, Close, Break or Shutdown event.

bug released released on @beta

All 4 comments

missing special handling for the CODE 12?

everything that is non-0 exist code, is an error - on all systems

and why did it exit with CTRL+C in the first place? when it gets killed (by this package) it gets an SIGINT not an SIGTERM

Edit: aside from that, i noticed an small problem - which got fixed in 96c30deee12e295738b93e28fad056e24ccaf40e (#407)

:tada: This issue has been resolved in version 7.0.0-beta.8 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

closing because this has been resolved in 7.0.0-beta.8

(and to stop it from getting stale anymore)

Was this page helpful?
0 / 5 - 0 ratings