Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close client rather than use process.exit in cli #415

Open
nholik opened this issue Apr 30, 2022 · 1 comment
Open

Close client rather than use process.exit in cli #415

nholik opened this issue Apr 30, 2022 · 1 comment

Comments

@nholik
Copy link

nholik commented Apr 30, 2022

When using this as a library in order to use via a CI process, all of the commands that interact with the database would hang indefinitely.

After reviewing the main CLI code in https://github.com/seppevs/migrate-mongo/blob/master/bin/migrate-mongo.js I noticed that process.exit was being used in all these cases. For my needs, a clean exit can happen by making sure to do a close on the client object, which then allows the process to exit normally without forcing it.

Specifically, you can see
here
https://github.com/seppevs/migrate-mongo/blob/master/bin/migrate-mongo.js#L75
and
https://github.com/seppevs/migrate-mongo/blob/master/bin/migrate-mongo.js#L96
both interact with a connection and have process.exit
where as the create command which requires no connection does not need this pattern to stop
https://github.com/seppevs/migrate-mongo/blob/master/bin/migrate-mongo.js#L48

My recommendation after observing this, which I can try my hand at a recommend PR if you'd like, would be to follow the same pattern in the CLI as I found where calling client.close will eliminate the need to force an exit.

@rabih
Copy link

rabih commented Jun 15, 2022

I am experiencing a similar issue with our CI process around this and was fortunate to see this issue.
@seppevs thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants