You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
We are executing heroku commands with Node and when we call heroku pipelines:add if the command succeeds, the child process never exits which hangs the parent process.
We were using execFile, but I switched to spawn so we could watch the output. If the command is run directly from the terminal, it works fine. Since pipelines are not supported in the API yet, exec-ing the toolbelt is the easiest way to implement this that I know. If we should try to require this module and use it directly instead, we could try that I guess.
I tried this with Node 0.10, 0.12, and 4.2 with the same result. We can't use 5 yet, so I haven't tried that. We are transitioning off of 0.10 over the next few months, but we still need this work until then.
What our code is doing (with dummy names for pipeline and app instead of the variables we pass):
but the callback is never called, the process doesn't exit, and the ps command still shows the heroku command running.
When using spawn to watch the output more carefully:
var spawn = require('child_process').spawn,
ls = spawn('heroku', ['pipelines:add', 'my-pipeline', '--stage', 'development', '--app', 'my-app-name']);
ls.stdout.on('data', function (data) {
console.log('$stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('$stderr: ' + data);
//if (/^done/.test(data)) {
// console.log('killing');
// ls.kill('SIGQUIT');
//}
});
ls.on('close', function (code) {
console.log('$child process exited with code ' + code);
});
With output:
$stdout:
$stderr: Adding my-app-name to my-pipeline pipeline as development...
$stderr: done
But we never get the 'close' event, and the process hangs.
Running the command directly in the terminal works fine:
$ heroku pipelines:add my-pipeline --stage development --app my-app-name
Adding my-app-name to my-pipeline pipeline as development... done
$ echo $?
0
$
Using the regex check for done in the stderr stream in the spawn example and force killing the process, or using the {timeout: 3000} option in execFile also work around the issue, but aren't very tidy.
The text was updated successfully, but these errors were encountered:
I'm going to cc @heroku/cli because I think this is probably an issue with the plugin architecture in general.
Having said that you can make API calls directly from your node script here's an example. The only thing to be aware of with that is that when we promote the API from beta you'll need to change the Accept header to 'application/vnd.heroku+json; version=3' when we do.
I'm pretty sure this is some kind of issue with stdin not being a tty, but I wasn't able to reproduce it. echo '' | heroku pipelines ... doesn't seem to have the same issue. Likely because that buffer is closed.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
We are executing heroku commands with Node and when we call
heroku pipelines:add
if the command succeeds, the child process never exits which hangs the parent process.We were using execFile, but I switched to spawn so we could watch the output. If the command is run directly from the terminal, it works fine. Since pipelines are not supported in the API yet, exec-ing the toolbelt is the easiest way to implement this that I know. If we should try to require this module and use it directly instead, we could try that I guess.
I tried this with Node 0.10, 0.12, and 4.2 with the same result. We can't use 5 yet, so I haven't tried that. We are transitioning off of 0.10 over the next few months, but we still need this work until then.
What our code is doing (with dummy names for pipeline and app instead of the variables we pass):
With the resulting output:
but the callback is never called, the process doesn't exit, and the
ps
command still shows the heroku command running.When using spawn to watch the output more carefully:
With output:
But we never get the 'close' event, and the process hangs.
Running the command directly in the terminal works fine:
Using the regex check for done in the stderr stream in the spawn example and force killing the process, or using the
{timeout: 3000}
option in execFile also work around the issue, but aren't very tidy.The text was updated successfully, but these errors were encountered: