RangeError: превышен максимальный размер стека вызовов
Итак, вот простая функция, которая использует 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 были байты, полученные каждый х с очень высокой скоростью (так как я на VPS). Мой торрент будет успешно загружен в считанные секунды (нашел его в /tmp/webtorrent/:D)
Однако это не решает RangeError, который вызван resolve();
линия
1 ответ
После небольшого исследования выяснилось, что 16384 - это байты, полученные каждым х с очень высокой скоростью (так как я на VPS). Мой торрент будет успешно загружен в считанные секунды (нашел его в /tmp/webtorrent/
:D)
Ошибка RangeError была вызвана моей функцией нормализации, которая оставляла объекты и делала их слишком большими.