Closed douginoz closed 1 year ago
Pretty late to respond but maybe it helps somebody else. I was seeing the same thing - probably for a different reason. But the thing that ultimately saved me was capturing console output.
https://github.com/puppeteer/puppeteer See item 3 under "Debugging Tips".
root@3a25c52f0402:/grafana-generate-pdf-nodejs# git diff ./grafana_pdf.js
diff --git a/grafana_pdf.js b/grafana_pdf.js
index aed8f5d..98e6634 100644
--- a/grafana_pdf.js
+++ b/grafana_pdf.js
@@ -32,6 +32,7 @@ const auth_header = 'Basic ' + new Buffer.from(auth_string).toString('base64');
});
const page = await browser.newPage();
+ page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
// Set basic auth headers
await page.setExtraHTTPHeaders({ 'Authorization': auth_header });
In my case I was running into a CORS issue.
PAGE LOG: centrifuge config JSHandle@object
PAGE LOG: client will connect to websocket endpoint
PAGE LOG: start connecting
PAGE LOG: Status disconnected -> connecting
PAGE LOG: WebSocket connection to 'wss://server1.example.com:3000/api/live/ws' failed: HTTP Authentication failed; no valid credentials available
PAGE LOG: transport level error JSHandle@object
PAGE LOG: disconnected: connection closed true
PAGE LOG: Status connecting -> disconnected
PAGE LOG: reconnect after 1937 milliseconds
PAGE LOG: Access to XMLHttpRequest at 'https://server2.example.com/login/grafana/api/new_way.cgi' from origin 'https://server1.example.com:3000' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
PAGE LOG: Failed to load resource: net::ERR_FAILED
PAGE LOG: start connecting
PAGE LOG: Status disconnected -> connecting
PAGE LOG: WebSocket connection to 'wss://server1.example.com:3000/api/live/ws' failed: HTTP Authentication failed; no valid credentials available
PAGE LOG: transport level error JSHandle@object
PAGE LOG: disconnected: connection closed true
PAGE LOG: Status connecting -> disconnected
PAGE LOG: reconnect after 3248 milliseconds
@douginoz Are you still facing this issue? Note: After cloning you may refer/change/debug the code of "grafana_pdf.js" this file as per your need and check if it solves your issue.
I'm afraid I can't even recall this error. I must have moved on from the problem afterwards, as I don't use Chrome now.
ubuntu 20.04, same machine as grafana is running on fresh install of google chrome: $ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb $ sudo dpkg -i google-chrome-stable_current_amd64.deb $ latest version of npm, puppeteer installed: $ npm version { 'grafana-pdf': '1.0.0', npm: '8.1.1', node: '12.21.0', v8: '7.8.279.23-node.45', uv: '1.40.0', zlib: '1.2.11', brotli: '1.0.9', ares: '1.17.1', modules: '72', nghttp2: '1.43.0', napi: '7', llhttp: '2.1.3', http_parser: '2.9.4', openssl: '1.1.1j', cldr: '37.0', icu: '67.1', tz: '2021a1', unicode: '13.0' }
Did a 'sudo npm install' (the 'npm clean install' doesn't work - 'clean' isn't a valid option)
When trying to run this, it hangs with: