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

Promise keep node process from exit #626

vothanhkiet opened this Issue May 22, 2015 · 2 comments


None yet
2 participants
Copy link

vothanhkiet commented May 22, 2015

I write a tool for migrating data using Bluebird promise, so that user can trigger this tool directly via node command. Example:

node migrate.js

The problem is, node process will not exist after complete all operation. Here is the content of main migrate.js, the exec() function return a promise.

var migrate = require('../elasticsearch/migrate');
var setting = require('../../config/setting');

var cmd = new migrate(, true);
    .then(function () {'Operation completed');
    .catch(function (err) {

At the moment I must trigger process.exit() to kill the process.


This comment has been minimized.

Copy link

petkaantonov commented May 22, 2015

Promise doesn't keep process alive, it is some other api that you are using. Try checking process._getActiveRequests() and process._getActiveHandles() to see what is keeping the process alive.


This comment has been minimized.

Copy link

vothanhkiet commented May 22, 2015

Thank for you support, after rechecking current open handles via process._getActiveHandles(), the process was kept from exiting because of Knex library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.