Skip to content

Promises API rejects even when operation successfully completes. #19

@repalash

Description

@repalash

The code checks for stderr.length to identify if the process existed successfully, but incase when logging is enable with -v or --log-level, it's written to stderr, which makes the promise API reject.

Here is a sample code that doesn't work:

await rclone.promises('command', {
    'progress': true, 'log-level': process.env.DEBUG ? 'DEBUG' : 'INFO'
  },
);

One that works:

const childProcess = rclone('command', {
    'progress': true, 'log-level': process.env.DEBUG ? 'DEBUG' : 'INFO',
    stdio: 'inherit',
  },
);
await new Promise((resolve, reject) => {
  childProcess.on('exit', (code) => {
    if (code === 0) {
      resolve();
    } else {
      reject(new Error(`Failed with code ${code}`));
    }
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions