Javascript Pupeter调试:查找导致错误的行
因此,我每x秒循环运行一次Puppeter bot(Javascript Pupeter调试:查找导致错误的行,javascript,puppeteer,Javascript,Puppeteer,因此,我每x秒循环运行一次Puppeter bot(robot.js),打开一个选项卡,从页面捕获一些数据,然后关闭选项卡。。。。直到下一个循环 所以它工作正常,我可以在控制台中看到数据日志,但每次 opening page 1 -> ok (node:11867) UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most like
robot.js
),打开一个选项卡,从页面捕获一些数据,然后关闭选项卡。。。。直到下一个循环
所以它工作正常,我可以在控制台中看到数据日志,但每次
opening page 1 -> ok
(node:11867) UnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
at CDPSession.send (/home/hostname/domains/example.com/robot/node_modules/puppeteer/lib/Connection.js:189:29)
at ExecutionContext.evaluateHandle (/home/hostname/domains/example.com/robot/node_modules/puppeteer/lib/ExecutionContext.js:89:75)
at ElementHandle.$ (/home/hostname/domains/example.com/robot/node_modules/puppeteer/lib/ElementHandle.js:272:50)
at Frame.$ (/home/hostname/domains/example.com/robot/node_modules/puppeteer/lib/FrameManager.js:357:34)
(node:11867) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:11867) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
opening page 2 -> ok
bot done successfully ... closing tab for the next loop
正如你所看到的,我得到一个错误,告诉我进程在进程中间已经关闭。奇怪的是,这个循环是成功的,并且工作没有问题
我不知道这是什么原因 这是我的问题。。。。有没有办法获得更多关于这一错误发生在哪一行(或与此有关)以及在robot.js中发生在哪里的信息我在错误堆栈中看到的只是引用了Puppeter内部模块,这在本例中对我来说非常无用。引入了Puppeter 1.9.0-错误现在应该指向代码中的实际行。即使给出正确的答案,任何示例代码都会更有帮助。@Md.AbuTaher,原始代码太长了,我必须清理一下。在关闭页面之前,请确保没有未决的承诺。分享代码,我很乐意帮助你。