Why isn't the 'finish' event firing in this Node.js code?
<p>Newbie to Node here. I'm trying to download a <code>.tar.xz</code> file and extract it to a directory via the code shown below:</p>

<pre><code>var request = require('request');
var tar = require('tar');
var xz = require('xz');

function downloadRaw(url, callback)
{
    return request({
        encoding: null,
        url: url
    }, callback);
}

function extractToDirectory(url, directory, callback)
{
    return downloadRaw(url)
        .pipe(new xz.Decompressor())
        .pipe(tar.Extract(directory))
        .on('finish', callback);
}
</code></pre>

<p>For some reason, the <code>'finish'</code> event on the tar stream does not seem to be firing, even after it finishes extracting the contents of the archive. <a href="https://github.com/npm/node-tar" rel="nofollow"><strong>tar</strong></a> is a library that's maintained by npm themselves, so I assume that I'm making some kind of mistake here. Anyway, why is this happening and what can I do to fix it?</p>