PDF Export Works on Production but Fails on Staging with Identical Configuration
bawaskaresha
FREEOP

4 months ago

Hello Railway Support Team,

I'm experiencing an issue where our PDF generation feature works perfectly on our production environment but consistently fails on staging environment, despite both having identical code and configuration.

Environment Details:

  • Service: Next.js (same service, different environments)

  • Production: Working 

  • Staging: Failing 

Configuration (Identical on Both):

railway.toml:

[build]

builder = "nixpacks"

[deploy]

healthcheckPath = "/healthz"

healthcheckTimeout = 30

restartPolicyType = "always"

[env]

PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = "true"

PUPPETEER_EXECUTABLE_PATH = "/usr/bin/chromium"

nixpacks.toml:

[phases.setup]

aptPkgs = [

  "chromium",

  "chromium-browser",

  "fonts-ipafont-gothic",

  "fonts-wqy-zenhei",

  "fonts-thai-tlwg",

  "fonts-kacst",

  "fonts-freefont-ttf",

  "libxss1",

  "libxtst6",

  "libnss3",

  "libnspr4",

  "libasound2t64",

  "libatk-bridge2.0-0",

  "libatk1.0-0",

  "libcups2",

  "libdbus-1-3",

  "libdrm2",

  "libgbm1",

  "libgtk-3-0",

  "libxcomposite1",

  "libxdamage1",

  "libxfixes3",

  "libxrandr2",

  "libpango-1.0-0",

  "libcairo2",

  "ca-certificates",

]

The Issue:

Production (Working):

  • Puppeteer launches successfully

  • PDF generation works perfectly

  • Using /usr/bin/chromium as configured

Staging (Failing):

  • API returns 500 error

  • Error: "Failed to generate PDF"

  • Deploy logs show: "An error occurred" (generic error)

What We've Verified:

  1. white_check_mark emoji Code is identical between environments (checked via GitHub)

  2. white_check_mark emoji railway.toml is identical (confirmed in Railway Settings)

  3. white_check_mark emoji Environment variables match in Railway dashboard

  4. white_check_mark emoji Both deployments show "Deployment successful"

  5. white_check_mark emoji Both use the same Next.js service

  6. white_check_mark emoji nixpacks configuration is identical

$10 Bounty

2 Replies

Railway
BOT

4 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


bawaskaresha
FREEOP

4 months ago

Grabbed these build and deploy logs from railway

Region: us-east4]

==============

Using Nixpacks

==============

context: npvz-H71J

╔══════════════════════════════ Nixpacks v1.38.0 ══════════════════════════════╗

║ setup      │ nodejs_18, pnpm-9_x, libnss3, libatk1.0-0, libatk-bridge2.0-0,  ║

║            │ libcups2, libgbm1, libasound2t64, libpangocairo-1.0-0, libxss1, ║

║            │ libgtk-3-0, libxshmfence1, libglu1, chromium                    ║

║──────────────────────────────────────────────────────────────────────────────║

║ install    │ npm install -g corepack@0.24.1 && corepack enable               ║

║            │ pnpm i --frozen-lockfile                                        ║

║──────────────────────────────────────────────────────────────────────────────║

║ build      │ pnpm run build                                                  ║

║──────────────────────────────────────────────────────────────────────────────║

║ start      │ pnpm run start                                                  ║

╚══════════════════════════════════════════════════════════════════════════════╝

internal

load build definition from Dockerfile

0ms

internal

load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1745885067

115ms

internal

load .dockerignore

0ms

internal

load build context

0ms

stage-0

FROM ghcr.io/railwayapp/nixpacks:ubuntu-1745885067@sha256:d45c89d80e13d7ad0fd555b5130f22a866d9dd10e861f589932303ef2314c7de

21ms

stage-0

RUN nix-env -if .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix && nix-collect-garbage -d cached

0ms

stage-0

COPY .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix cached

0ms

stage-0

WORKDIR /app/ cached

0ms

stage-0

RUN sudo apt-get update && sudo apt-get install -y --no-install-recommends libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgbm1 libasound2t64 libpangocairo-1.0-0 libxss1 libgtk-3-0 libxshmfence1 libglu1 chromium

56s

Processing triggers for libc-bin (2.39-0ubuntu8.4) ...

stage-0

COPY . /app/.

162ms

stage-0

RUN npm install -g corepack@0.24.1 && corepack enable

1s

changed 1 package in 1s

stage-0

RUN pnpm i --frozen-lockfile

16s

Done in 14s using pnpm v10.20.0

stage-0

COPY . /app/.

1s

stage-0

RUN pnpm run build

1m 15s

ƒ (Dynamic) server-rendered on demand

stage-0

RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile

142ms

stage-0

COPY . /app

77ms

auth

sharing credentials for production-us-east4-eqdc4a.railway-registry.com

0ms

=== Successfully Built! ===

Run:

docker run -it production-us-east4-eqdc4a.railway-registry.com/58e8d46f-26ed-4433-8004-7b73f6d670ea:99132b6c-67e7-485a-9712-1ab235037a8a

Build time: 212.12 seconds

==================== Starting Healthcheck ====================

Path: /healthz

Retry window: 30s

[1/1] Healthcheck succeeded!


Loading...