pupeteer调试:查找哪条线提示错误

时间:2018-10-03 13:30:38

标签: javascript puppeteer

所以我每隔x秒钟循环运行puppeteer bot(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在哪里发生的更多信息?

我在错误堆栈中看到的所有内容都是在引用puppeteer内部模块,在这种情况下,对我而言这几乎没有用

1 个答案:

答案 0 :(得分:0)

Puppeteer 1.9.0引入了async stacks-现在,该错误应使您指向代码中的实际行。