zipreport / zipreport-server

PDF conversion daemon for ZipReport
MIT License
2 stars 0 forks source link

Headless Chrome Debug Logs / Console Logs #7

Open Darxor opened 3 weeks ago

Darxor commented 3 weeks ago

Hello!

I couldn't find this in docs here or in rod's docs (except https://github.com/go-rod/rod/issues/330). Is there a way to access headless chrome's logs / chrome's console events in debug mode?

Information (errors and console messages) there is useful to debug cases when report generates fine with "zipreport debug" on local machine but fails with headless browser inside the container, eg. when "zpt-view-ready" is never issued for some reason.

Darxor commented 3 weeks ago

Sorry to be posting in closed issue. I've just tried the new parameter and did not see my message or error on the log.

Did I run it wrong?

I've added this to my js code to ensure message and error are fired before the print event.

    class handlers extends Paged.Handler {
        constructor(chunker, polisher, caller) {
            super(chunker, polisher, caller);
        }

        afterPreview(pages) {
            console.log('heyooo');
            console.error('noooooo');
            console.log('zpt-view-ready');
        }
    }
    (function () {
        Paged.registerHandlers(handlers);
    })()

Here's how I ran the container

docker run -p 6543:6543 ghcr.io/zipreport/zipreport-server:latest \
          -e ZIPREPORT_API_KEY="my-api-mey" \
          -e ZIPREPORT_DEBUG="true" \
          -e ZIPREPORT_CONSOLE="true"
{"level":"info","certFile":"/etc/ssl/server.crt","keyFile":"/etc/ssl/server.key","address":"0.0.0.0:6543","message":"starting API webserver with SSL"}
{"level":"info","id":"898d0479-d636-496b-9309-7dc701d4af78","address":"localhost:42000","message":"server address"}
{"level":"info","message":"Starting server and listening on localhost:42000"}
{"level":"info","id":"898d0479-d636-496b-9309-7dc701d4af78","message":"Browser acquired"}
{"level":"info","id":"898d0479-d636-496b-9309-7dc701d4af78","size":155030,"elapsedTime":2.487489524,"message":"finished job in 2.487490 seconds"}
{"level":"info","address":"localhost:42000","message":"Shutting down server "}
9:42PM INF Request ip=172.17.0.1 latency=4727.726343 method=POST path=/v2/render status=200 user_agent=python-requests/2.32.2

Don't mind the long runtime, its faster when container is built under arm64, but I can't see errors or messages then either.

joao-pinheiro commented 3 weeks ago

Hi,

It seems docker is picky with order of parameters (env vars should come first), so I've updated the documentation:

docker run -e ZIPREPORT_API_KEY="my-api-key" \
    -e ZIPREPORT_DEBUG="true" \
    -p 6543:6543 ghcr.io/zipreport/zipreport-server:2.1.2

And during this process I detected some (blatant, I may add) errors in zipreport-server docker startup script, that should be fixed now (there is a new release).

Also, I don't recommend using :latest for production purposes, because it is quite difficult to understand if its really running the latest version, so I've updated the README examples to use explicit version tags.

Thank you for your feedback, and let me know if you find any other problem :)

joao-pinheiro commented 2 weeks ago

closing, assuming everything is working now