解決したいこと
バックエンドにてnode、puppeteer、Google chartsで作成したグラフ画像をサーバー内に保存したいがエラーが発生するので解決したい。
発生している問題
直近1年程全く問題なくチャート画像を作成し保存出来ていたが、ある日突然エラーが発生するようになった。
エラーメッセージを自分なりに解読すると、puppeteerが上手く動いていないのではと考えていますが、具体的にどこを修正したらよいかわからない為ご教授頂きたいです。
(特にnode等の設定は変更していません)
エラーメッセージ
CentOS8
1node:internal/process/promises:246 2 triggerUncaughtException(err, true /* fromPromise */); 3 ^ 4 5TimeoutError: Navigation timeout of 5000 ms exceeded 6 at /root/node_modules/puppeteer/lib/LifecycleWatcher.js: 100:111 7 at async DOMWorld.setContent (/root/node_modules/puppeteer/lib/DOMWorld.js:171:23) 8 at async Page.setContent (/root/node_modules/puppeteer/lib/Page.js:550:9) 9 at async Object.renderGoogleChart [as render] (/root/node_modules/google-charts-node/lib/render.js:37:3) 10 at async /var/www/html/chart_maker.js:36:16 11 -- ASYNC -- 12 at Frame.<anonymous> (/root/node_modules/puppeteer/lib/helper.js:116:19) 13 at Page.setContent (/root/node_modules/puppeteer/lib/Page.js:550:46) 14 at Page.<anonymous> (/root/node_modules/puppeteer/lib/helper.js:117:27) 15 at Object.renderGoogleChart [as render] (/root/node_modules/google-charts-node/lib/render.js:37:14) 16 at processTicksAndRejections (node:internal/process/task_queues:96:5) 17 at async /var/www/html/chart_maker.js:36:16
google-charts-node github URL
https://github.com/typpo/google-charts-node
ソースコード
js
1//chart_maker.js 2const GoogleChartsNode =require('/root/node_modules/google-charts-node'); 3const fs =require('fs'); 4 5const drawChartFunc = ` 6function drawChart() { 7 const data = google.visualization.arrayToDataTable([ 8 ['City', '2010 Population',], 9 ['New York City, NY', 8175000], 10 ['Los Angeles, CA', 3792000], 11 ['Chicago, IL', 2695000], 12 ['Houston, TX', 2099000], 13 ['Philadelphia, PA', 1526000] 14 ]); 15 16 const options = { 17 title: 'test}', 18 chartArea: {width: '50%'}, 19 hAxis: { 20 title: 'Total Population', 21 minValue: 0 22 }, 23 vAxis: { 24 title: 'City' 25 } 26 }; 27 28 const chart = new google.visualization.BarChart(container); 29 chart.draw(data, options); 30} 31`; 32 33// Render the chart to image 34(async () => { 35 36 const image = await GoogleChartsNode.render(drawChartFunc, { 37 38 width: 500, 39 height: 500 40 }); 41 42 fs.writeFileSync('/var/www/html/chart.png', image); 43})();

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。