Studiosity / grover

A Ruby gem to transform HTML into PDFs, PNGs or JPEGs using Google Puppeteer/Chromium
MIT License
945 stars 109 forks source link

Grover::JavaScript::UnknownError #253

Closed koenhandekyn closed 2 months ago

koenhandekyn commented 3 months ago

i'm trying to get grover running in a docker on hetzner cloud

using ENV GROVER_NO_SANDBOX=true using RUN npm install puppeteer@22 using RUN curl -fsSL https://deb.nodesource.com/setup_22.x using ARG RUBY_VERSION=3.3.4 using RUN npx puppeteer browsers install chrome

so the system is ubuntu with ruby 3.3.4, nodejs v22, puppeteer v22, the correct chrome get's installed and then i hit this very magical error which i don't manage to debug further.

first i was no ARM and i was installing manual chromium, pointing puppeteer to the executable and then hit exactly the same error. i thought it was ARM related, so switched the server to AMD/X86 but in the end i'm now hitting exactly the same issue.

ps: i'm using puppeteer@22 because v23 had a bug that was blocking me also. (see #252)

any help appreciated.

koenhandekyn commented 3 months ago

serious debugging later and with help of @eneagoe we traced it to JEMALLOC that was installed on the base image (a rails 7.2 app). clearing up LD_PRELOAD solved the issue (basically disabling JEMALLOC).

taylorthurlow commented 3 months ago

My understanding is that chrome has issues running with jemalloc, so you would need to compile Ruby with jemalloc specifically, or patch it. LD_PRELOAD is applying it to everything.

abrom commented 2 months ago

Not so sure about that @taylorthurlow. The issue is Chrome/Puppeteer/Node related. Using JEMALLOC in Ruby isn't going to come into play here. But as @koenhandekyn indicated, setting LD_PRELOAD to nothing will overload the system ENV setting, thus disable the loading of jemalloc. Although you'd likely want to check that there aren't any other libraries being pre-loaded as blanket clearing out that ENV var could cause other unexpected behaviours!

Reference: https://github.com/Studiosity/grover?tab=readme-ov-file#setting-custom-environment-variable-for-node