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

Javascript RangeError:超出了最大调用堆栈大小,javascript,node.js,webtorrent,Javascript,Node.js,Webtorrent,下面是一个使用webtorrent的简单函数: 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');

下面是一个使用webtorrent的简单函数:

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
重复,直到内存耗尽

编辑:经过一番研究,结果表明16384是以非常高的速率每x接收的字节数(因为我使用的是VPS)。我的torrent将在几秒钟内成功下载(在/tmp/webtorrent/:D中找到)


但是,这并不能解决由
resolve()引起的范围错误

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

Range错误是由我的normalize函数引起的,该函数会留下对象并使其过大