下载文件时节点渲染过程消失



我正在编写一个小型电子程序,(目前(能够从Google云端硬盘下载多个大文件。有些文件太大而无法扫描,因此它会诱使服务器相信单击了"无论如何下载"按钮。

问题是,在 3、7 或 12 个文件之后,Chrome 开发工具窗口会显示"渲染过程消失"。

3 个文件: - 下载解锁打开,同时尝试连续 3 次下载相同的阻止文件。第 4 个文件崩溃。

7 个文件: - 混合了 5 个未阻止的文件和 2 个已阻止的文件,并打开了下载解锁。第 8 个文件(未阻止(请求崩溃

12 个文件: - 下载 9 个未阻止的文件和 3 个被阻止的文件,同时关闭下载解锁

因此,我得出的结论是,"解锁"文件会占用 12 个可能的"插槽"中的 3 个。然后,一切(或至少数字(都会有意义。

取消阻止的工作原理是在同一 url 上发送另一个具有相同 cookie 字符和 ?confirm=xxxx 的请求。

请注意,如果我使用另一个具有 100mb 测试文件的文件提供程序,则整个文件在 12 个文件后不会崩溃。

如果您能为我指出正确的方向,那将非常有帮助。

下面是所用代码的一个非常简化的版本。请注意,缺少很多变量声明和其他东西,但这些部分似乎是有问题的:

// downloadmanager.js
function DownloadManager(pack) {
var _this = this;
this.downloadpackages = function (package, data, cb) {
sync.fiber(function () {
...
Object.keys(ht_distinct_urls).forEach(function (url) {
localfile = sync.await(_this.download(remotefile, sync.defer()));
console.log("Downloaded:" + localfile);
});
});
}
this.dl = function (remotefile, cb) {
request(request_options, (err, response, body) => {
// cb() in this location makes it crash at the 13th file
cb(null, "");
});
// cb() in this location doesnt make it crash (but also not download anything)
//cb(null, "");
}
this.download = function (remotefile, cb) {
// Try to download
_this.dl(remotefile, function (err, data) {
if (data.downloaded) { // It worked
cb(err, data);
} else if (data.unblocked) { // It was able to get a code to unblock it
_this.dl(data, cb); // Try again with the new cookie and the code
} else {
// Fck it, just return the data anyway for debugging
cb(err, data);
}
});
};
}
// renderer.js
sync.fiber(function () {
var pack = getPackage();
var dm = new DownloadManager(pack);
var download_result = sync.await(dm.downloadpackages(pack, ht_distinct_urls, sync.defer()));
console.log(download_result);
});

好的,似乎我在发布这个问题时找到了解决方案。无论如何我都会发布它,也许它可以帮助其他人......

似乎谷歌阻止即时下载。在下载之间添加 5 秒的超时解决了我的问题。还没有测试超时可以有多低,但也许问题无论如何都通过设置超时回调解决了......

最新更新