1

When program runs await page.evaluate(...);, there is error throwing out:

Error: Page crashed!
    at Page._onTargetCrashed (/usr/src/app/node_modules/puppeteer/lib/Page.js:170:24)
    at CDPSession.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/Page.js:125:56)
    at CDPSession.emit (events.js:203:13)
    at CDPSession._onMessage (/usr/src/app/node_modules/puppeteer/lib/Connection.js:200:12)
    at Connection._onMessage (/usr/src/app/node_modules/puppeteer/lib/Connection.js:112:17)
    at WebSocket.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/WebSocketTransport.js:41:24)
    at WebSocket.onMessage (/usr/src/app/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:203:13)
    at Receiver.receiverOnMessage (/usr/src/app/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:203:13)
[2019-09-19T02:59:56.202Z] Error for printPdf()
Error: Protocol error (Runtime.callFunctionOn): Target closed.
    at /usr/src/app/node_modules/puppeteer/lib/Connection.js:183:56
    at new Promise (<anonymous>)
    at CDPSession.send (/usr/src/app/node_modules/puppeteer/lib/Connection.js:182:12)
    at ExecutionContext.evaluateHandle (/usr/src/app/node_modules/puppeteer/lib/ExecutionContext.js:106:44)
    at ExecutionContext.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:111:23)
    at ExecutionContext.evaluate (/usr/src/app/node_modules/puppeteer/lib/ExecutionContext.js:48:31)
    at ExecutionContext.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:111:23)
    at DOMWorld.evaluate (/usr/src/app/node_modules/puppeteer/lib/DOMWorld.js:112:20)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
  -- ASYNC --
    at Frame.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:110:27)
    at Page.evaluate (/usr/src/app/node_modules/puppeteer/lib/Page.js:782:43)
    at Page.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:111:23)
    at printPdf (/usr/src/app/puppeteer.js:219:16)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async /usr/src/app/puppeteer.js:133:21 {
  message: 'Protocol error (Runtime.callFunctionOn): Target closed.'
}

I tried to increase Azure Kubernetes VM size to have better CPU and Memory, it worked and problem was gone. However, it happened suddenly again and I don't want to upgrade VM size to EXTREMELY model.

How to solve it completely?


Further adding htop screen capture for reference:
(It was not reaching to 80% yet) enter image description here

DaiKeung
  • 1,077
  • 1
  • 19
  • 38
  • What url are you trying to render with `puppeteer`? Which is your environment? – Yasen Sep 19 '19 at 06:31
  • Hi @Yasen, the URL is local URL index.html with calling my JS functions to do render for PDF content. In my case, I tried to prepare 600 photos for rendering and faced error. Environments both Production and Staging. – DaiKeung Sep 19 '19 at 06:38
  • Are you hitting [resource limits](https://stackoverflow.com/a/57295869/5627599) regarding CPU/memory? How many browsers, pages, etc. are you starting? – Thomas Dondorf Sep 19 '19 at 15:13
  • Hi @ThomasDondorf, I deploy 4 pods on 4CPU with 8GB Memory VM (Checked "Allocatable Resource" only ~ 3xxx m & 5.x GB) So, I assigned 850m with 1.2Gi for each pod. if there are 600 photos, around 50 pages in PDF. (but when printing PDF, program will render all components to calculate the height then make the line break, maybe there is problem). However, when I used commands `kubectl top pods` and `kubectl top nodes`, checked CPU and Memory were not used up to 100% yet. – DaiKeung Sep 20 '19 at 02:51
  • Added htop screen capture for reference. – DaiKeung Sep 20 '19 at 03:57
  • @DaiKeung Not used up to 100%, but close? CPU/memory might still be the problem then. Maybe you can [parallelize the jobs](https://stackoverflow.com/a/52233124/5627599)? – Thomas Dondorf Sep 20 '19 at 18:44
  • Thanks @ThomasDondorf. Your package may work but I would not test it under company's restriction. Sorry that I am not allow to download 3rd party code which is not used widely. Do you have other solutions? – DaiKeung Sep 23 '19 at 09:14
  • @DaiKeung am facing the same issue, how did u fix it? – palAlaa Feb 17 '20 at 11:05
  • 1
    @palAlaa I just upgrade machine with better CPU, then solved it. – DaiKeung Feb 18 '20 at 03:37

0 Answers0