简体   繁体   中英

Puppeteer crashes on browser.close() with: Received signal 11 <unknown>

I have not found any question that addresses an issue I face with a puppeteer script. The script runs fine and produces a screenshot, except that it crashes at the end in browser.close() . I reduced the script to its essence to reproduce the issue:

import puppeteer from 'puppeteer';
import { PendingXHR } from 'pending-xhr-puppeteer';

const puppeteerOptions = {
    headless:           true,
    dumpio:             true,
    userDataDir:        './user-data',
    defaultViewport:    null,
    args: [
        '--window-size=1200,800',
        '--disable-notifications',
        '--disable-geolocation',
        '--disable-infobars',
        '--disable-extensions',
        '--disable-session-crashed-bubble',
        '--disable-gpu',
        '--disable-features=NetworkService',
        '--disable-audio-output',
        '--mute-audio',
        '--silent-debugger-extension-api',
        '--single-process',
        '--disable-setuid-sandbox',
        '--full-memory-crash-report',
        '--unlimited-storage'
    ]
}
let url = process.argv[2];
if(!url) {
    console.log('Specify URL');
    process.exit(1);
}

const sleep = m => new Promise(r => setTimeout(r, m));  // sleep is a setTimeout that can be awaited

(async() => {
    console.log('==> initialize headless browser');
    const browser = await puppeteer.launch(puppeteerOptions);
    const page = await browser.newPage();
    const pendingXHR = new PendingXHR(page);
    try {
        console.log('==> load ' + url);
        await page.setDefaultNavigationTimeout(0);
        await page.goto(url, { waitUntil: 'networkidle0' });    // wait for page load
        console.log('==> await page.setRequestInterception');
        await page.setRequestInterception(true);                // intercept requests, for next line
        console.log('==> await pendingXHR.waitForAllXhrFinished');
        await pendingXHR.waitForAllXhrFinished();               // wait for all requests to finish
        console.log('==> generate screenshot');
        await page.screenshot({ path: './screenshot.png', fullPage: true });
        await sleep(2000);
    } catch (error) {
        console.log('==> Catch ERROR: ' + error.message);
    }
    console.log('==> page.close()');
    await page.close();
    await sleep(2000);
    console.log('==> browser.close()');
    await browser.close();
    console.log('==> script end');
})();

Script output with Received signal 11 <unknown> 000000000000 crash:

-bash-4.2$ node demo https://www.google.com/
==> initialize headless browser
[0818/152036.508006:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.

DevTools listening on ws://127.0.0.1:45180/devtools/browser/82b03d2a-eaba-44b0-b6f5-e571a8cbe093
==> load https://www.google.com/
==> await page.setRequestInterception
==> await pendingXHR.waitForAllXhrFinished
==> generate screenshot
==> page.close()
==> browser.close()
Received signal 11 <unknown> 000000000000
#0 0x5601f8f7c612 base::debug::CollectStackTrace()
#1 0x5601f8edb193 base::debug::StackTrace::StackTrace()
#2 0x5601f8f7c131 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f9371ffd5d0 (/usr/lib64/libpthread-2.17.so+0xf5cf)
#4 0x5601f8f366f4 base::SupportsUserData::GetUserData()
#5 0x5601f6c9ca0e content::RenderProcessHostImpl::UnregisterHost()
#6 0x5601f6c9c1f4 content::RenderProcessHostImpl::~RenderProcessHostImpl()
#7 0x5601f6c9ce2e content::RenderProcessHostImpl::~RenderProcessHostImpl()
#8 0x5601f6c9bfa8 content::RenderProcessHostImpl::ShutDownInProcessRenderer()
#9 0x5601f68ac5df content::BrowserMainLoop::ShutdownThreadsAndCleanUp()
#10 0x5601f68adead content::BrowserMainRunnerImpl::Shutdown()
#11 0x5601fe67a557 headless::HeadlessContentMainDelegate::RunProcess()
#12 0x5601f8a66942 content::RunBrowserProcessMain()
#13 0x5601f8a67ed9 content::ContentMainRunnerImpl::RunBrowser()
#14 0x5601f8a67a70 content::ContentMainRunnerImpl::Run()
#15 0x5601f8a64c54 content::RunContentProcess()
#16 0x5601f8a655e4 content::ContentMain()
#17 0x5601f8abf3ba headless::(anonymous namespace)::RunContentMain()
#18 0x5601f8abf0c5 headless::HeadlessShellMain()
#19 0x5601f52da1e3 ChromeMain
#20 0x7f936d8903d5 __libc_start_main
#21 0x5601f52da02a _start
  r8: 00007ffefefdc440  r9: 0000000000000001 r10: 0000000000000002 r11: 00005601feeeb5a0
 r12: 000004e80065d400 r13: 00005601fee60530 r14: 000004e80023cd08 r15: 000004e80065d400
  di: 000004e80023cd18  si: 00005601f354dd90  bp: 00007ffefefdc470  bx: 000004e80035c700
  dx: badbad00badbad08  ax: 000004e80023cd18  cx: badbad00badbad00  sp: 00007ffefefdc470
  ip: 00005601f8f366f4 efl: 0000000000010206 cgf: 0000000000000033 erf: 0000000000000000
 trp: 000000000000000d msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
==> script end
-bash-4.2$

I am using the chromium that npm installs with puppeteer.

Environment used:

-bash-4.2$ uname -a
Linux xxxxxxxx-02 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
-bash-4.2$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
-bash-4.2$ node --version
v14.20.0
-bash-4.2$ grep '"version"' /usr/lib/node_modules/puppeteer/package.json
  "version": "16.1.1"
-bash-4.2$ grep '"version"' /usr/lib/node_modules/pending-xhr-puppeteer/package.json
  "version": "2.3.3"
-bash-4.2$ ls /usr/lib/node_modules/puppeteer/.local-chromium/
linux-1022525

Any idea how to fix this crash?

UPDATE: I filed a bug report at https://github.com/puppeteer/puppeteer/issues/8818

UPDATE 2022-08-26: Related chromium bug: https://crbug.com/1356885

UPDATE 2022-09-26: Confirmed chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1356885

Same issue. appears to happen only on.close() and the rest of the process runs fine. there are some errors on launch but they dont seem to affect the output. I dont know whether to care about these up front errors or not but the stack dump on.close() definitely is not good? do you still think it is a chromium bug or related, I am still assuming it is my fault. just dont know how to fix any of this: input welcome! :)

[0926/160220.212118:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable.

[0926/160220.271606:ERROR:angle_platform_impl.cc(43)] DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1

ERR: DisplayVkXcb.cpp:59 (initialize): xcb_connect() failed, error 1
[0926/160220.271685:ERROR:angle_platform_impl.cc(43)] Display.cpp:992 (initialize): ANGLE Display::initialize error 12289: Not initialized.

ERR: Display.cpp:992 (initialize): ANGLE Display::initialize error 12289: Not initialized.

[0926/160220.271775:ERROR:gl_display.cc(506)] EGL Driver message (Critical) eglInitialize: Not initialized.

[0926/160220.271786:ERROR:gl_display.cc(879)] eglInitialize SwANGLE failed with error EGL_NOT_INITIALIZED

[0926/160220.271815:ERROR:gl_ozone_egl.cc(23)] GLDisplayEGL::Initialize failed.

[0926/160220.276601:ERROR:gpu_channel_manager.cc(839)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.

[0926/160220.276638:ERROR:shared_image_stub.cc(489)] SharedImageStub: unable to create context

[0926/160220.276661:ERROR:gpu_channel.cc(608)] GpuChannel: Failed to create SharedImageStub

version: HeadlessChrome/105.0.5173.0

[0926/160221.622346:ERROR:gpu_channel_manager.cc(839)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.

[0926/160221.622396:ERROR:shared_image_stub.cc(489)] SharedImageStub: unable to create context

[0926/160221.622411:ERROR:gpu_channel.cc(608)] GpuChannel: Failed to create SharedImageStub

[0926/160221.622701:ERROR:gpu_channel_manager.cc(839)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.

[0926/160221.622711:ERROR:shared_image_stub.cc(489)] SharedImageStub: unable to create context

[0926/160221.622720:ERROR:gpu_channel.cc(608)] GpuChannel: Failed to create SharedImageStub

Error on.close() - stack dump: (after the program runs successfully otherwise.

Received signal 11 <unknown> 000000000000
#0 0x555a40aaf612 base::debug::CollectStackTrace()
#1 0x555a40a0e193 base::debug::StackTrace::StackTrace()
#2 0x555a40aaf131 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f8dfab15730 (/lib/x86_64-linux-gnu/libpthread-2.28.so+0x1272f)
#4 0x555a40a696f4 base::SupportsUserData::GetUserData()
#5 0x555a3e7cfa0e content::RenderProcessHostImpl::UnregisterHost()
#6 0x555a3e7cf1f4 content::RenderProcessHostImpl::~RenderProcessHostImpl()
#7 0x555a3e7cfe2e content::RenderProcessHostImpl::~RenderProcessHostImpl()
#8 0x555a3e7cefa8 content::RenderProcessHostImpl::ShutDownInProcessRenderer()
#9 0x555a3e3df5df content::BrowserMainLoop::ShutdownThreadsAndCleanUp()
#10 0x555a3e3e0ead content::BrowserMainRunnerImpl::Shutdown()
#11 0x555a461ad557 headless::HeadlessContentMainDelegate::RunProcess()
#12 0x555a40599942 content::RunBrowserProcessMain()
#13 0x555a4059aed9 content::ContentMainRunnerImpl::RunBrowser()
#14 0x555a4059aa70 content::ContentMainRunnerImpl::Run()
#15 0x555a40597c54 content::RunContentProcess()
#16 0x555a405985e4 content::ContentMain()
#17 0x555a405f23ba headless::(anonymous namespace)::RunContentMain()
#18 0x555a405f20c5 headless::HeadlessShellMain()
#19 0x555a3ce0d1e3 ChromeMain
#20 0x7f8df940f09b __libc_start_main
#21 0x555a3ce0d02a _start
  r8: 00007ffd410e2060  r9: 0000000000000001 r10: 0000000000000002 r11: 0000555a46a1e5a0
 r12: 00002fdc0068cf00 r13: 0000555a46993530 r14: 00002fdc00210c08 r15: 00002fdc0068cf00
  di: 00002fdc00210c18  si: 0000555a3b080d90  bp: 00007ffd410e2090  bx: 00002fdc003541c0
  dx: badbad00badbad08  ax: 00002fdc00210c18  cx: badbad00badbad00  sp: 00007ffd410e2090
  ip: 0000555a40a696f4 efl: 0000000000010206 cgf: 002b000000000033 erf: 0000000000000000
 trp: 000000000000000d msk: 0000000000000000 cr2: 0000000000000000

[end of stack trace]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM