Hi,
seems you are not handling error, and probably there are some connectivity issues, I suppose
torrent.getMetadata().then(function data (buf) {
fs.writeFileSync('tmp.torrent', buf)
}, function err (err) {
console.log('ERR', err)
})
see error, handle it...