RangeError:超出最大调用堆栈大小

时间:2015-12-28 19:47:24

标签: javascript node.js webtorrent

所以这是一个使用webtorrent的简单函数:

#TYPE Selected.Microsoft.ActiveDirectory.Management.ADUser

并称之为:

addTorrent (opts) {
  return new Promise((resolve, reject) => {
    try {
      console.log('in try catch');
      let torrent = wtClient.add(opts.source, (torrent) => {
        console.log('client.add callback');
        var nled = normalize(torrent);
        console.log('normalized ', torrent.infoHash);
        resolve(nled);
      });
      console.log('after add')
      torrent.on('download', (chunkSize) => {
        console.log(chunkSize);
        this.emit('torrent:' + torrent.infoHash + ':download', chunkSize);
      });
      console.log('after on');
    } catch(err) {
      console.log(pe.render(err));
      process.exit(1);
      reject(err);
    }
  });
}

这是输出:

var MAGNET_URI = 'magnet:?xt=urn:btih:09e37f73e51f403bb543517f0d0a2e1283d61eb0&dn=archlinux-2015.12.01-dual.iso&tr=udp://tracker.archlinux.org:6969&tr=http://tracker.archlinux.org:6969/announce';
socketClient.connect().then(() => {
    console.log('Connected to webtorrent');
    return socketClient.status();
}).then((res) => {
    console.log(res);
    return socketClient.addTorrent({source: MAGNET_URI});
}).then((data) => {
    console.log('Added torrent:', data);
}).catch((err) => {
    console.log(err);
});

root@ubuntu-512mb-lon1-01:~/pTorrent# DEBUG=webtorrent,ut_metadata,dht,tracker,ut_pex npm start > pTorrent@0.0.2 start /root/pTorrent > node server.js --env=dev webtorrent new webtorrent (peerId 2d5757303036332d323330643939666634313638, nodeId c59e8b616c66cf97437fd69f4ae037d00709b83b) +0ms Listening at localhost:8080 Opening your system browser... Client connected... WEBPACK STUFF Client connected... in try catch webtorrent add +42s after add after on client.add callback normalized 09e37f73e51f403bb543517f0d0a2e1283d61eb0 error occured for addTorrent RangeError: Maximum call stack size exceeded - Torrent.hasOwnProperty - index.js:47 _hasBinary [pTorrent]/[has-binary-data]/index.js:47:17 - index.js:37 _hasBinary [pTorrent]/[has-binary-data]/index.js:37:15 - index.js:47 _hasBinary [pTorrent]/[has-binary-data]/index.js:47:40 - index.js:47 _hasBinary [pTorrent]/[has-binary-data]/index.js:47:40 - index.js:37 _hasBinary [pTorrent]/[has-binary-data]/index.js:37:15 - index.js:47 _hasBinary [pTorrent]/[has-binary-data]/index.js:47:40 - index.js:47 _hasBinary [pTorrent]/[has-binary-data]/index.js:47:40 - index.js:37 _hasBinary [pTorrent]/[has-binary-data]/index.js:37:15 - index.js:47 _hasBinary [pTorrent]/[has-binary-data]/index.js:47:40 16384 16384 16384 16384 重复,直到内存不足为止。

编辑:经过一番研究后发现,16384是每个x以非常高的速率接收的字节数(因为我在VPS上)。我的洪流将成功下载几秒钟(在/ tmp / webtorrent /:D中找到)

但是,这并不能解决由16384

引起的RangeError

1 个答案:

答案 0 :(得分:0)

经过一番研究,结果证明16384是每个x以非常高的速率接收的字节(因为我在VPS上)。我的torrent将在几秒内成功下载(在/tmp/webtorrent/:D)

中找到

RangeError是由我的normalize函数引起的,它会使对象离开并使其太大。