This error still rarely occurs for me. So I added the optional option closeDelay to launch options, which adds an additional delay between the last browser interaction and browser closing
4. Clone this pull request into parent folder
5. Install dependencies ```npm i --save-dev```
6. Run ```npm run build```
7. Replace this files with the according ones in the node_modules/puppeteer-stream folder of the step 1 project
dist/PuppeteerStream.d.ts
dist/PuppeteerStream.js
8. Open command line, navigate to step 1 project and execute ```node index.js```
9. Confirm browser and program close without error
The Fixes
Headless: "new"
TargetCloseError
This error still rarely occurs for me. So I added the optional option closeDelay to launch options, which adds an additional delay between the last browser interaction and browser closing
Doc
Mention new headless mode and does some cleanup
How to test in debugging
npm i puppeteer-stream
(async () => { const browser = await launch({ executablePath: "C:/Program Files/Google/Chrome/Application/chrome.exe", headless: "new", closeDelay: 500, defaultViewport: { width: 1920, height: 1080 } }); const page = await browser.newPage(); await page.goto("https://www.youtube.com/embed/DzivgKuhNl4?autoplay=1"); const stream = await getStream(page, { audio: true, video: true });
})();
dist/PuppeteerStream.d.ts dist/PuppeteerStream.js