UnhandledPromiseRejectionWarning: Error: Evaluation failed: Object
出现,它指向page.evaluate
,无处不在。虽然,我怀疑这主要是在处理大量.ts文件时发生的。UnhandledPromiseRejectionWarning: Error: Protocol error (Network.getResponseBody): Request content was evicted from inspector cache
。 关于我该如何做的任何建议-
解决page.evaluate
问题。
当我完成特定的请求/数据时,请清除检查器缓存,并使Puppeteer保存大量的.ts文件。
/* This whole code is inside an async function */
/* .... code for finding array ts .... */
let requests = [], prs = [];
page.on('request', req => {
if(req.url().endsWith('.ts')){
requests.push(req);
}
});
/*
ts[i].ts contains all the links to a stream/video's .ts files
ts[i].filename contains the name of that video
*/
for (i = 0; i < ts.length; i++) {
for(const ele of ts[i].ts){
// Not writing await is on purpose; for saving all the pending promises
let x = page.evaluate(async (link, file) => {
// jQuery is included in the page itself
return $.ajax({
url : link,
headers : {"custom" : file}
});
}, ele, ts[i].filename);
prs.push(x);
}
// This makes request.response() be filled
await Promise.all(prs);
for(let req of requests){
let res = await req.response().buffer();
let fname = req.headers().customHeader;
// Data written to relevant file
fs.appendFileSync(fname, res);
}
prs = [];
requests = [];
}
答案 0 :(得分:0)
存在伪造者回购中的缓存错误问题:#1599
devtools保留在内存中的资源内容大小受到限制。资源的上限为10Mb,存储所有资源的上限为100Mb
该协议中有实验性支持来修改以下限制:Network.enable。
和here's how尝试启用更大的文件:
await page._client.send('Network.enable', {
maxResourceBufferSize: 1024 * 1204 * 100,
maxTotalBufferSize: 1024 * 1204 * 200,
})
也许这对您有帮助。