HollowMan6/mdbook-pdf

Trying to build a (fairly simple) book panics mdbook-pdf

Popaulol opened this issue · 11 comments

Generating PDF, please be patient...
thread '<unnamed>' panicked at 'Unhandled WebSocket error for Chrome #Some(8): Capacity(MessageTooLong { size: 34247580, max_size: 16777216 })', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-pdf-headless_chrome-0.1.5/src/browser/transport/web_socket_connection.rs:100:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2023-03-20T17:59:54Z ERROR headless_chrome::browser::transport] Transport loop got disconnected from WS's sender (Chrome #Some(8))
thread 'main' panicked at 'Unable to make method calls because underlying connection is closed, so PDF generation failed!', src/main.rs:213:21
``

This occures both when trying to use the docker image, aswell as trying to to run mdbook natively.

Screenshot from 2023-03-20 20-13-46

That's interesting, as it's a duplication of #16 , and you mentioned you have the issue even under docker, but weirdly I'm experiencing no issue on both the CI and my PC.

Could you provide the book even you mentioned it's fairly simple, and please tell me what kind of OS you are using?

I have now both tried this on Linux and windows and inside WSL2. Always the same error.

Here's a link to the book: https://github.com/Popaulol/romantik-stl

Please tell me when you don't need it anymore, as it's pretty useless to keep around on my gh account.

The docker run was only attempted on my main Linux (Debian) Mashine.
I also now tried it on my windows 10 Laptop, basically identical error:

C:\Users\Dell\Desktop\Paul\romantik-stl>mdbook build
2023-03-20 21:00:06 [INFO] (mdbook::book): Book building has started
2023-03-20 21:00:06 [INFO] (mdbook::book): Running the html backend
2023-03-20 21:00:06 [INFO] (mdbook::book): Running the pdf backend
2023-03-20 21:00:06 [INFO] (mdbook::renderer): Invoking the "pdf" renderer
Generating PDF, please be patient...
thread '<unnamed>' panicked at 'Unhandled WebSocket error for Chrome #Some(3212): Capacity(MessageTooLong { size: 34255932, max_size: 16777216 })', C:\Users\Dell\.cargo\registry\src\github.com-1ecc6299db9ec823\mdbook-pdf-headless_chrome-0.1.5\src\browser\transport\web_socket_connection.rs:100:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2023-03-20T20:00:13Z ERROR headless_chrome::browser::transport] Transport loop got disconnected from WS's sender (Chrome #Some(3212))
thread 'main' panicked at 'Unable to make method calls because underlying connection is closed, so PDF generation failed!', C:\Users\Dell\.cargo\registry\src\github.com-1ecc6299db9ec823\mdbook-pdf-0.1.6\src\main.rs:213:21
2023-03-20 21:00:13 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2023-03-20 21:00:13 [ERROR] (mdbook::utils): Error: Rendering failed
2023-03-20 21:00:13 [ERROR] (mdbook::utils):    Caused By: The "pdf" renderer failed

C:\Users\Dell\Desktop\Paul\romantik-stl>

I can reproduce this issue with your book, will look into this soon.

Tomorrow i'd try reviving an old win10 install i still have laying around on an ssd where a old version of mdbook-pdf is installed to try and maybe built it with that.

okay thanks ;)

Looks like it's because some of the images in your book are too large. Will try to lift up that limit in the dependency a little bit (hope that is possible). You are now OK to delete your book repo, thank you so much for providing your book.

Hi! I've tried my best and it looks like that limit is for the protocol (usize::max_value()), so unfortunately I can't help you more with resolving this issue. https://github.com/snapview/tungstenite-rs/blob/edb237754084bfb18a301ac8a3a42612af64ae19/src/protocol/message.rs#L138-L151 The only suggestion I can give is that, try to compress your pictures so that it can fit within this limit.

I've already filed an issue for the rust-headless-chrome, hope they can find some way to solve this: rust-headless-chrome/rust-headless-chrome#385

Thank you.

I downscaled the images and the export worked.

I'll delete my repo now.

Hi! An update that I have removed the limit with my own fork of tungstenite, now mdbook-pdf should be OK when generating very large pdfs / images. https://github.com/HollowMan6/mdbook-pdf-tungstenite/commit/632185567b4b9118ada457509e966585b8d19b2e

You can have the latest one by reinstalling mdbook-pdf with cargo install mdbook-pdf -f