Selenium webdriverjs - Download file and wait for completion

I've checked out all the other related posts on the matter, but nothing really works for me when trying to perform the following:

  • Download a file (using request)
  • Waiting for it to complete
  • Printing the size of the file

My current code is as follows after playing with a bunch of variations:

var downloadFile = function(url, cb) {
  req.get(url).pipe(fs.createWriteStream('/tmp/example.pdf')).on('finish', function(){
    return cb("done");

downloadFile('https://linkto/example.pdf', function(isDone){
var stats = fs.statSync('/tmp/example.pdf');

The problem is the file size prints as 0 and is logged prior to the "done" callback, which I am assuming is because the file isn't downloaded completely. Is there a way not using async/await to wait for the file to download before getting its actual size // or using it elsewhere?