Sparticuz / chromium

Chromium (x86-64) for Serverless Platforms
MIT License
1.03k stars 71 forks source link

[BUG] Error: spawn ETXTBSY #242

Closed muhammedsaidkaya closed 7 months ago

muhammedsaidkaya commented 8 months ago

Environment

Expected Behavior

After restarting the container/pod, the binary file should be released.

Current Behavior

The chromium executable binary held by a process. Even if I restart the process and although binary file is not called multiple times, I can not launch the puppetter because of the file is locked.

Stack trace

Something went wrong during puppeteer.launch Error: spawn ETXTBSY
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at Object.spawn (node:child_process:761:9)
    at new Process (/app/dist/index.js:77190:56)
    at launch (/app/dist/index.js:77149:14)
    at ChromeLauncher.launch (/app/dist/index.js:88071:54)
    at async generatePdf (/app/dist/index.js:275048:15)

Steps to Reproduce

import puppeteer from "puppeteer-core"
import chromium from "@sparticuz/chromium"

const width = 595
const height = 842
const defaultViewport = { width, height }

async function generatePdf() {
let args = ["--font-render-hinting=none"]
let browser

args = args.concat(...chromium.args)
console.log(chromium.args)
try {
        browser = await puppeteer.launch({
            args,
            defaultViewport,
            ignoreHTTPSErrors: true,
            headless: "new",
            executablePath: await chromium.executablePath(),
        })
    } catch (err) {
        console.error("Something went wrong during puppeteer.launch", err?.stack)
        throw Error("Something went wrong during puppeteer.launch")
    }
}

Possible Solution

I suspect that binary file remains in locked status if process killed and not gracefully shutdown.

Sparticuz commented 7 months ago

I've never tried it with anything other that plain lambda. You can try increasing the memory available? Though if you are using a container, I'd probably just install normal chromium in the container.

muhammedsaidkaya commented 7 months ago

I've never tried it with anything other that plain lambda. You can try increasing the memory available? Though if you are using a container, I'd probably just install normal chromium in the container.

Okay. Thanks for your answer.