Error: Future resolved more than once While running R script using Fibers

I am new to meteor and trying to develop an app for running R script using a webtool. I have used the Meteor method as below.

    exec_srv_paleoCar : function(cmd) {
	      	return future.wait();

And the client Call is as below.

  var cmd_ras_ext = 'Rscript  '+ curr_dir + 'Rscript\\raster_extent.R ' +  curr_dir +' ' + in_file_name_ext ;
  alert(cmd_ras_ext);'exec_srv_paleoCar',cmd_ras_ext,(error, result) => 
    if (error) {

The method is executing successfully and I am able to get the output and use it in my client.

But the meteor server is getting restarted with the below message.

W20170613-22:55:10.230(-5)? (STDERR) windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:261
W20170613-22:55:10.232(-5)? (STDERR) throw new Error(‘Future resolved more than once’);
W20170613-22:55:10.238(-5)? (STDERR) ^
W20170613-22:55:10.242(-5)? (STDERR)
W20170613-22:55:10.244(-5)? (STDERR) Error: Future resolved more than once
W20170613-22:55:10.246(-5)? (STDERR) at Object.Future.return
W20170613-22:55:10.259(-5)? (STDERR) at server/main.js:26:17
W20170613-22:55:10.261(-5)? (STDERR) at ChildProcess.exithandler (child_process.js:191:7)
W20170613-22:55:10.262(-5)? (STDERR) at emitTwo (events.js:87:13)
W20170613-22:55:10.265(-5)? (STDERR) at ChildProcess.emit (events.js:172:7)
W20170613-22:55:10.272(-5)? (STDERR) at maybeClose (internal/child_process.js:862:16)
W20170613-22:55:10.275(-5)? (STDERR) at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)

Could you please help me in resolving this error ?

Meteor has already set up the fiber and future, together with the necessary future.wait and future.return. So your resolution pre-empts the resolution set up by Meteor.

There’s a few possible ways to handle this:

  1. If you aren’t interested in stderr, use Meteor.wrapAsync to wrap the exec:
const wrappedExec = Meteor.wrapAsync(exec);

  exec_srv_paleoCar: function (cmd) {
    return wrappedExec(cmd);
  1. Write a small Promise wrapper and then use a Promise chain or async and await.

  2. Begin a brand-new fiber with its own future within the method. That will allow Meteor’s future to resolve independently of yours.

EDIT: Turns out there’s already a Promise-wrapped exec, which simplifies 2).

Hi Rob,

Thanks for the help!

I used the Meteor.wrapAsync method as well. This seems to work pretty fine and resolved the earlier issue. but this is leading to a different problem where my client is getting refreshed unlimited times.

I20170615-11:23:47.392(-5)? -112.004166667 -111.004166667 35.995833334 36.995833334
=> Client modified – refreshing (x164)

I am not sure if both are related or not.

var cmd_exe_paleocar = 'Rscript '+ curr_dir + 'Rscript\example.R ’ ;
//alert(cmd_exe_paleocar);‘exec_srv_paleoCar’,cmd_exe_paleocar,function(error, result)
if (error) {

Server side method

'exec_srv_paleoCar': function(command) 
  var res;
  res = cmd(command);
  return res;



I was able to resolve this issue. The problem was encountered due to an image generated by my script in the public folder which leads to the refreshing of the client every time.

I removed that part and saved the image to a different location. Now, the client is not getting refreshed.

Thanks for the help, once again!

1 Like