kstulgys
HOBBYOP
2 months ago
It seems after I am calling the endpoint that uses puppeteer I get this error:
stderr:
326 | return new Promise((resolve, reject) => {
^
327 | const onClose = (errorOrCode) => {
error: Failed to launch the browser process: Code: 127
324 | }
325 | waitForLineOutput(regex, timeout = 0) {
328 | cleanup();
329 | reject(new Error([
/tmp/chromium: error while loading shared libraries: libnspr4.so: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://pptr.dev/troubleshooting
at onClose (/app/node_modules/@puppeteer/browsers/lib/esm/launch.js:329:28)
at emit (node:events:98:22)
at #handleOnExit (node:child_process:520:14)Here is my deps:
import puppeteer, { type PDFOptions, type Viewport } from "puppeteer-core";
import chromium from "@sparticuz/chromium";Then:
const browser = await puppeteer.launch({
args: [
...chromium.args,
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-gpu",
"--disable-dev-shm-usage",
],
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath(),
headless: chromium.headless,
});1 Replies
passos
MODERATOR
2 months ago
Hey, I'm afraid Railway does not have a way to customize the build/start script to install those extra missing packages (libnspr4). If you want, you can install it via code with the following code:
import { $ } from "bun";
await $"apt-get update -y && apt-get install libnspr4 libnss3 expat -y"But it comes at the cost of installing it every time the code starts up. In this case, I would recommend using a normal service with a GitHub repo. Railway will automatically detect the Bun environment, and if the error happens again, you can instruct Railway to fix it with the following environment variable:
RAILPACK_DEPLOY_APT_PACKAGES=libnspr4 libnss3 expat