Spawning child process in method and writing streams to mongo FileCollection hangs?

I have an issue where the method I am calling from a client some times never sends back the “updated” DDP message to the client which causes the client to hang.

I have tracked down the problem to one line in the code. Its where I set up to log my input stream to a child-process that I spawn using vsivsi:meteor-file-collection. This used to work on Meteor 1.3 but after upgrading to 1.4 it stopped working and I think there is some error in the code.

So I spawn a child process using require('child_process'). I then attach some events for the input/output stream. I also attach a FileCollection stream so that the input stream is logged to the mongo database. This line seems to break the code sometimes (see below). The meter method sometimes never sends back the “updated” DDP message to the client when I use this code and therefore the client hangs, waiting for the method to fully return. Can you see any issues with the code?

  const self = this;
  const childProcess = ChildProcess.spawn(command, cmdArguments);

  //Store stdout/stderr
  this.stdout = "";
  childProcess.stdout.on('data', (chunk) => self.stdout += chunk.toString());
  this.stderr = "";
  childProcess.stderr.on('data', (chunk) => self.stderr += chunk.toString());

  //Create ways to wait for data
  this.waitForStdout = new Future();
  this.waitForStderr = new Future();

  childProcess.stdout.on('end', () => {
    self.waitForStdout.return();
  });
  childProcess.stderr.on('end', () => {
    self.waitForStderr.return();
  });
  childProcess.stdout.on('error', () => {
    self.waitForStdout.throw();
  });
  childProcess.stderr.on('error', () => {
    self.waitForStderr.throw();
  });

  //Pipe stdin, stdout and stderr to mongodb
  this.myInputStream().pipe(this.getMongoDbSStdinStream(someId)); // Return a FileCollection <--- THIS LINE SOMETIMES FAILS CAUSING THE CLIENT TO HANG SINCE "updated" MESSAGE IS NEVER SENT BACK

  //Write stdin to child process
  this.myInputStream.pipe(childProcess.stdin);

  //Attach process exit callback
  childProcess.on('exit', Meteor.bindEnvironment(function (code, signal) {
    self.waitForStdout.wait();
    self.waitForStderr.wait();
......
......
......