windmill-labs / windmill

Open-source developer platform to power your entire infra and turn scripts into webhooks, workflows and UIs. Fastest workflow engine (13x vs Airflow). Open-source alternative to Retool and Temporal.
https://windmill.dev
Other
9.88k stars 463 forks source link

bug: cancelling a script does not kill chromium processes #4198

Open whollacsek opened 2 months ago

whollacsek commented 2 months ago

Describe the bug

In the script editor if we click on the test button on the right panel then click on cancel button while a puppeteer instance is running the associated chromium process is not kill properly which lead to maximum CPU usage.

To reproduce

  1. Create new script with minimal puppeteer usage:
    
    import 'puppeteer-core'
    import puppeteer from 'puppeteer-extra'

export async function main() { const browser = await puppeteer.launch( { executablePath: '/usr/bin/chromium', headless: true, args: ['--no-sandbox'] } )

const page = await browser.newPage() await page.goto('https://www.google.com') // ... do more work here await browser.close() }


2. Click on test on the right panel
3. Click on cancel on the right panel before the script is done
4. CPU shoots up and chromium process is not killed

### Expected behavior

No chromium process should be left

### Screenshots

_No response_

### Browser information

_No response_

### Application version

CE v1.375.0-1-gfbcac1e0a

### Additional Context

_No response_
rubenfiszel commented 2 months ago

Try this:

    args: ['--single-process', '--no-zygote', '--no-sandbox']

from https://thedavidbarton.github.io/blog/chromium-instances-remain-active-in-the-background-after-browser-disconnect/

whollacsek commented 2 months ago

It doesn't seem to work with those args, however I just tried adding MAX_WAIT_FOR_SIGINT=1 to the worker container and the child process is killed (https://github.com/windmill-labs/windmill/pull/3094#issuecomment-1917709635)