人偶调试:查找导致错误的行

pupeteer debuging : finding which line is cuzing the error

所以我 运行 puppeteer bot (robot.js) 每隔 x 秒循环打开一个选项卡,从页面捕获一些数据并关闭选项卡....直到下一个循环

所以它工作正常,我可以在控制台中看到数据日志,但每次我都得到

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 内部模块,这对我来说在这种情况下几乎没用

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