node-export-server icon indicating copy to clipboard operation
node-export-server copied to clipboard

Pool not released after (a specific) Puppeteer error

Open kreintjes opened this issue 9 months ago • 7 comments

We are running the Highcharts export server on Heroku. At some point we get some Puppeteer detached frame errors. We are not sure why, maybe because of the specific chart configs being exported (to SVG). However, those export requests crashing isn't that big of a deal, but after those errors the worker pool seems to be exhausted (old workers are not released to the pool) and all subsequent requests crash with "Error encountered when acquiring an available entry". They keep crashing until we manually restart the export server.

So in detail, we first get two of these errors (we have a minWorker pool size of 2):

Request to export server not successful. code: 400, response: {"statusCode":400,"message":"[pool] In pool.postWork: Attempted to use detached Frame 'B3381E6334D5B8B0CADB3E9197D43969'."}

After which all subsequent requests crash with:

Request to export server not successful. code: 400, response: {"statusCode":400,"message":"[pool] In pool.postWork: For request with ID e0b3bd5f9ec04233ae22320e5ab5f370 - Error encountered when acquiring an available entry: 5001.070848ms."}

Looking at the code in pool.js, the worker should be released after the first error, but for some reason it doesn't and we can't acquire any new workers afterwards. So we end up with a running export server process with no workers in the pool at all, which seems pretty useless. Only way to fix this is to (manually) restart the process.

Any help with this would be appreciated!

kreintjes avatar Mar 06 '25 15:03 kreintjes

Sorry for the late reply here!

This issue is potentially fixed in version 5.0, that will be published to NPM this week. We very much welcome your feedback when you have tried that version!

Stian Totland Product Manager, Highsoft

stitot avatar Mar 19 '25 07:03 stitot

great v5 is coming in the next hour then (?) :)

Pascal76 avatar Mar 21 '25 22:03 Pascal76

Yes, a bit delayed, but v5 is now available at https://www.npmjs.com/package/highcharts-export-server.

stitot avatar Mar 24 '25 12:03 stitot

no problem, it is better to deploy a monday than the end of the week :)

Pascal76 avatar Mar 24 '25 13:03 Pascal76

when run in Docker (/bin/docker run -u 0:0 -v /apache_sites/jbm:/apache_sites/jbm --rm --tmpfs=/run highcharts_es /usr/local/bin/highcharts-export-server -v)

`blabla Mon Mar 24 2025 14:45:03 GMT+0100 [warning] - [cache] Could not fetch the https://cdnjs.cloudflare.com/ajax/libs/highcharts/maps/12.1.2/modules/map.js. The script might not exist in the requested version. Mon Mar 24 2025 14:45:03 GMT+0100 [warning] - [cache] Could not fetch the https://cdnjs.cloudflare.com/ajax/libs/highcharts/stock/12.1.2/indicators/indicators-all.js. The script might not exist in the requested version. Mon Mar 24 2025 14:45:03 GMT+0100 [notice] - [cache] Writing a new manifest. Mon Mar 24 2025 14:45:03 GMT+0100 [notice] - [browser] Attempting to get a browser instance (try 1). Mon Mar 24 2025 14:45:03 GMT+0100 [warning] - [browser] Failed to launch a browser instance - retrying (attempt 1/25). Error: Failed to launch the browser process! [0324/144503.750061:ERROR:zygote_host_impl_linux.cc(99)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (file:///node-export-server/node_modules/@puppeteer/browsers/lib/esm/launch.js:301:24)
at Interface.emit (node:events:530:35)
at Interface.close (node:internal/readline/interface:526:10)
at Socket.onend (node:internal/readline/interface:252:10)
at Socket.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1698:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Mon Mar 24 2025 14:45:03 GMT+0100 [notice] - [browser] Retry to open a browser (attempt 1/25). Mon Mar 24 2025 14:45:07 GMT+0100 [notice] - [browser] Attempting to get a browser instance (try 2). Mon Mar 24 2025 14:45:07 GMT+0100 [warning] - [browser] Failed to launch a browser instance - retrying (attempt 2/25). Error: Failed to launch the browser process! [0324/144507.767083:ERROR:zygote_host_impl_linux.cc(99)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (file:///node-export-server/node_modules/@puppeteer/browsers/lib/esm/launch.js:301:24)
at Interface.emit (node:events:530:35)
at Interface.close (node:internal/readline/interface:526:10)
at Socket.onend (node:internal/readline/interface:252:10)
at Socket.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1698:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

... `

Pascal76 avatar Mar 24 '25 13:03 Pascal76

Sorry, @Pascal76, but a config change slipped the changelog. Sandbox is now default, so update config.json to:

{"puppeteer": {"args": ["--no-sandbox"]}}

Start with highcharts-export-server --enableServer 1 --loadConfig config.json

stitot avatar Mar 24 '25 15:03 stitot

typo => {"puppeteer": {"args": ["--no-sandbox"]}}

Pascal76 avatar Mar 24 '25 15:03 Pascal76