Spaces:
Running
Running
Rollback to Puppeteer 22.x - v24.x has critical PDF encoding bug
Browse files- Puppeteer 24.x generates corrupted 240MB PDFs from 1.5MB images
- Rollback to stable v22.0.0
- Remove v24.x specific configurations
Files changed (3)
- Dockerfile+1-6
- package.json+2-2
- server.js+7-7
9 unmodified lines1011121314151617181920212223242526279 unmodified linesfonts-noto-core \fonts-noto-color-emoji \libxss1 \ca-certificates \--no-install-recommends \&& rm -rf /var/lib/apt/lists/*# 2. Set working directoryWORKDIR /app# 3. Configure Puppeteer to skip bundled Chrome download (use system chromium)ENV PUPPETEER_SKIP_DOWNLOAD=trueENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium# 4. Install Node.js DependenciesCOPY package.json .RUN npm install9 unmodified lines101112131415161718192021229 unmodified linesfonts-noto-core \fonts-noto-color-emoji \libxss1 \--no-install-recommends \&& rm -rf /var/lib/apt/lists/*# 2. Set working directoryWORKDIR /app# 3. Install Node.js DependenciesCOPY package.json .RUN npm install
123456789101112{"name": "pdf-server","version": "1.1.0","description": "Puppeteer PDF Generator for Hugging Face Spaces","main": "server.js","dependencies": {"express": "^4.18.2","puppeteer": "^24.0.0","cors": "^2.8.5"},"scripts": {123456789101112{"name": "pdf-server","version": "1.0.1","description": "Puppeteer PDF Generator for Hugging Face Spaces","main": "server.js","dependencies": {"express": "^4.18.2","puppeteer": "^22.0.0","cors": "^2.8.5"},"scripts": {
46 unmodified lines47484950515253545556575859606162636465666746 unmodified linesconst totalWaitTime = Math.min(baseWaitTime + sizeWaitTime, 8000); // Cap at 8s maxconsole.log(`[PDF-GEN] Calculated wait times: base=${baseWaitTime}ms, size=${sizeWaitTime}ms, total=${totalWaitTime}ms`);// Launch Chrome using system Chromium (configured via env var)browser = await puppeteer.launch({executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || '/usr/bin/chromium',args: ['--no-sandbox','--disable-setuid-sandbox','--disable-dev-shm-usage','--font-render-hinting=none','--disable-gpu','--disable-software-rasterizer','--memory-pressure-off'],headless: true});console.log('[PDF-GEN] Browser launched successfully');const page = await browser.newPage();46 unmodified lines47484950515253545556575859606162636465666746 unmodified linesconst totalWaitTime = Math.min(baseWaitTime + sizeWaitTime, 8000); // Cap at 8s maxconsole.log(`[PDF-GEN] Calculated wait times: base=${baseWaitTime}ms, size=${sizeWaitTime}ms, total=${totalWaitTime}ms`);// Launch Chrome// We use the installed 'chromium' from apt-getbrowser = await puppeteer.launch({executablePath: '/usr/bin/chromium',args: ['--no-sandbox','--disable-setuid-sandbox','--disable-dev-shm-usage', // Critical for Docker'--font-render-hinting=none', // Better font rendering'--disable-gpu', // Disable GPU for stability in Docker'--disable-software-rasterizer','--memory-pressure-off'],headless: 'new'});const page = await browser.newPage();
Dockerfile+1-6
package.json+2-2
server.js+7-7