[英]Error: Protocol error (Fetch.continueRequest): Invalid InterceptionId
I am using Puppeteer and chrome dev tools to intercept network responses and modify them if necessary.我正在使用 Puppeteer 和 chrome 开发工具来拦截网络响应并在必要时修改它们。 I use the following code.
我使用以下代码。
const client = page._client;
await client.send("Fetch.enable", {
patterns: [{ requestStage: "Response" }]
});
client.on("Fetch.requestPaused", async event => {
const { requestId, request, responseStatusCode, responseErrorReason } = event;
console.log(`Request "${requestId}" ${responseStatusCode} ${responseErrorReason} ${request.url} paused.`);
const responseCdp = await client.send("Fetch.getResponseBody", { requestId });
// TODO Modify response
await client.send("Fetch.continueRequest", { requestId });
});
But this fails intermittently (like 50 % of the time) with the following error但这会间歇性地失败(比如 50% 的时间)并出现以下错误
Error: Protocol error (Fetch.continueRequest): Invalid InterceptionId.
What could possibly cause this issue ?什么可能导致这个问题?
Turned out I had made a set of mistakes原来我犯了一系列错误
page.goto
in my code, which was messing up the interceptor.page.goto
实例,这弄乱了拦截器。 Correcting them resolve this issue.更正它们可以解决此问题。 What came in handy was to run puppetter with
headless: false
and inspecting the network of of chromium.派上用场的是运行 puppetter with
headless: false
并检查铬的网络。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.