question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use browser.createIncognitoBrowserContext() with the --no-sandbox and --single-process args

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.4.0-next.1526938802806
  • Platform / OS version: Fedora 28
  • URLs (if applicable):
  • Node.js version: 8.10.0

What steps will reproduce the problem?

Run this code:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    args: ['--no-sandbox', '--single-process'],
    dumpio: true
  });
  // Create a new incognito browser context.
  const context = await browser.createIncognitoBrowserContext();
  // Create a new page in a pristine context.
  const page = await context.newPage();
  // Do stuff
  await page.goto('https://example.com');
})();

It is really similar to the one documented here. The only differences are:

What is the expected result?

The page is created in the incognito context and I can use it to go to the given URL.

What happens instead?

When I run the code with DEBUG=*, I get the following error:

Protocol error (Target.createTarget): Target closed
puppeteer:protocol SEND ► {"id":1,"method":"Target.setDiscoverTargets","params":{"discover":true}} +0ms
puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"304bc7ef-3b66-413c-9997-bb8b09fe43e6","type":"browser","title":"","url":"","attached":false}}} +3ms
puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"9368F0E33E62C767DEAE0815BD3A1C36","type":"page","title":"","url":"about:blank","attached":false,"browserContextId":"41BAE1700F691DBD664C11935550ED7C"}}} +0ms
puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"fbda019a-ecf1-4886-a831-eb790b31606d","type":"browser","title":"","url":"","attached":true}}} +1ms
puppeteer:protocol ◀ RECV {"id":1,"result":{}} +1ms
puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"9368F0E33E62C767DEAE0815BD3A1C36","type":"page","title":"about:blank","url":"about:blank","attached":false,"browserContextId":"41BAE1700F691DBD664C11935550ED7C"}}} +0ms
puppeteer:target target.url() +0ms
puppeteer:target target.url() +0ms
puppeteer:browser browser.createIncognitoBrowserContext() +0ms
puppeteer:protocol SEND ► {"id":2,"method":"Target.createBrowserContext","params":{}} +0ms
puppeteer:protocol ◀ RECV {"id":2,"result":{"browserContextId":"42F52C519F23EFAC3F27E0AF7A7400A5"}} +1ms
puppeteer:browserContext browserContext.newPage() +0ms
puppeteer:protocol SEND ► {"id":3,"method":"Target.createTarget","params":{"url":"about:blank","browserContextId":"42F52C519F23EFAC3F27E0AF7A7400A5"}} +0ms
[0525/154945.922111:FATAL:render_process_host_impl.cc(3752)] Check failed: render_process_host->InSameStoragePartition( BrowserContext::GetStoragePartition(browser_context, site_instance, false )).
#0 0x55f1e0fccc8c base::debug::StackTrace::StackTrace()
#1 0x55f1e0f53600 logging::LogMessage::~LogMessage()
#2 0x55f1dfee109a content::RenderProcessHostImpl::GetProcessHostForSiteInstance()
#3 0x55f1dff9a85e content::SiteInstanceImpl::GetProcess()
#4 0x55f1dffca07a content::WebContentsImpl::Init()
#5 0x55f1dffbfd98 content::WebContentsImpl::CreateWithOpener()
#6 0x55f1dffbfba4 content::WebContents::Create()
#7 0x55f1e4e557d5 headless::HeadlessWebContentsImpl::Create()
#8 0x55f1e4e59a89 headless::HeadlessBrowserContextImpl::CreateWebContents()
#9 0x55f1e4e6a075 headless::protocol::TargetHandler::CreateTarget()
#10 0x55f1e4e6a25d headless::protocol::TargetHandler::CreateTarget()
#11 0x55f1e4e8aefb headless::protocol::Target::DispatcherImpl::createTarget()
#12 0x55f1e4e859e0 headless::protocol::Browser::DispatcherImpl::dispatch()
#13 0x55f1e4e8cc4a headless::protocol::UberDispatcher::dispatch()
#14 0x55f1e4e62d34 headless::HeadlessDevToolsManagerDelegate::HandleCommand()
#15 0x55f1dfcad89f content::DevToolsSession::DispatchProtocolMessage()
#16 0x55f1dfca15b9 content::DevToolsAgentHostImpl::DispatchProtocolMessage()
#17 0x55f1dfca5ac7 content::DevToolsHttpHandler::OnWebSocketMessage()
#18 0x55f1e0f3f03c base::debug::TaskAnnotator::RunTask()
#19 0x55f1e0f578a7 base::MessageLoop::RunTask()
#20 0x55f1e0f57d77 base::MessageLoop::DoWork()
#21 0x55f1e0f5a7bf base::(anonymous namespace)::WorkSourceDispatch()
#22 0x7f7356bde8ad g_main_context_dispatch
#23 0x7f7356bdec78 <unknown>
#24 0x7f7356bded10 g_main_context_iteration
#25 0x55f1e0f5a682 base::MessagePumpGlib::Run()
#26 0x55f1e0f76cf5 base::RunLoop::Run()
#27 0x55f1dfc66051 content::BrowserMainLoop::MainMessageLoopRun()
#28 0x55f1dfc65e53 content::BrowserMainLoop::RunMainMessageLoopParts()
#29 0x55f1dfc687a2 content::BrowserMainRunnerImpl::Run()
#30 0x55f1e4e5ce30 headless::HeadlessContentMainDelegate::RunProcess()
#31 0x55f1e0c83160 content::RunNamedProcessTypeMain()
#32 0x55f1e0c83d48 content::ContentMainRunnerImpl::Run()
#33 0x55f1e0c8dc04 service_manager::Main()
#34 0x55f1e0c81df4 content::ContentMain()
#35 0x55f1e4e5be29 headless::(anonymous namespace)::RunContentMain()
#36 0x55f1e4e5beb2 headless::HeadlessBrowserMain()
#37 0x55f1e0c8abcf headless::HeadlessShellMain()
#38 0x55f1df28a1ac ChromeMain
#39 0x7f7352cb018b __libc_start_main
#40 0x55f1df28a02a _start

Received signal 6 #0 0x55f1e0fccc8c base::debug::StackTrace::StackTrace() #1 0x55f1e0fcc7f1 base::debug::(anonymous namespace)::StackDumpSignalHandler() #2 0x7f7358cd0fc0 <unknown> #3 0x7f7352cc3f2b gsignal #4 0x7f7352cae561 abort #5 0x55f1e0fcb645 base::debug::BreakDebugger() #6 0x55f1e0f53a4a logging::LogMessage::~LogMessage() #7 0x55f1dfee109a content::RenderProcessHostImpl::GetProcessHostForSiteInstance() #8 0x55f1dff9a85e content::SiteInstanceImpl::GetProcess() #9 0x55f1dffca07a content::WebContentsImpl::Init() #10 0x55f1dffbfd98 content::WebContentsImpl::CreateWithOpener() #11 0x55f1dffbfba4 content::WebContents::Create() #12 0x55f1e4e557d5 headless::HeadlessWebContentsImpl::Create() #13 0x55f1e4e59a89 headless::HeadlessBrowserContextImpl::CreateWebContents() #14 0x55f1e4e6a075 headless::protocol::TargetHandler::CreateTarget() #15 0x55f1e4e6a25d headless::protocol::TargetHandler::CreateTarget() #16 0x55f1e4e8aefb headless::protocol::Target::DispatcherImpl::createTarget() #17 0x55f1e4e859e0 headless::protocol::Browser::DispatcherImpl::dispatch() #18 0x55f1e4e8cc4a headless::protocol::UberDispatcher::dispatch() #19 0x55f1e4e62d34 headless::HeadlessDevToolsManagerDelegate::HandleCommand() #20 0x55f1dfcad89f content::DevToolsSession::DispatchProtocolMessage() #21 0x55f1dfca15b9 content::DevToolsAgentHostImpl::DispatchProtocolMessage() #22 0x55f1dfca5ac7 content::DevToolsHttpHandler::OnWebSocketMessage() #23 0x55f1e0f3f03c base::debug::TaskAnnotator::RunTask() #24 0x55f1e0f578a7 base::MessageLoop::RunTask() #25 0x55f1e0f57d77 base::MessageLoop::DoWork() #26 0x55f1e0f5a7bf base::(anonymous namespace)::WorkSourceDispatch() #27 0x7f7356bde8ad g_main_context_dispatch #28 0x7f7356bdec78 <unknown> #29 0x7f7356bded10 g_main_context_iteration #30 0x55f1e0f5a682 base::MessagePumpGlib::Run() #31 0x55f1e0f76cf5 base::RunLoop::Run() #32 0x55f1dfc66051 content::BrowserMainLoop::MainMessageLoopRun() #33 0x55f1dfc65e53 content::BrowserMainLoop::RunMainMessageLoopParts() #34 0x55f1dfc687a2 content::BrowserMainRunnerImpl::Run() #35 0x55f1e4e5ce30 headless::HeadlessContentMainDelegate::RunProcess() #36 0x55f1e0c83160 content::RunNamedProcessTypeMain() #37 0x55f1e0c83d48 content::ContentMainRunnerImpl::Run() #38 0x55f1e0c8dc04 service_manager::Main() #39 0x55f1e0c81df4 content::ContentMain() #40 0x55f1e4e5be29 headless::(anonymous namespace)::RunContentMain() #41 0x55f1e4e5beb2 headless::HeadlessBrowserMain() #42 0x55f1e0c8abcf headless::HeadlessShellMain() #43 0x55f1df28a1ac ChromeMain #44 0x7f7352cb018b __libc_start_main #45 0x55f1df28a02a _start r8: 0000000000000000 r9: 00007ffc708ad8b0 r10: 0000000000000008 r11: 0000000000000246 r12: 00007ffc708ae068 r13: 00000000000000c6 r14: 00007ffc708ae070 r15: 00007ffc708adb59 di: 0000000000000002 si: 00007ffc708ad8b0 bp: 00007ffc708adb00 bx: 0000000000000006 dx: 0000000000000000 ax: 0000000000000000 cx: 00007f7352cc3f2b sp: 00007ffc708ad8b0 ip: 00007f7352cc3f2b efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000 [end of stack trace] Calling _exit(1). Core file will not be generated. (node:29943) UnhandledPromiseRejectionWarning: Error: Protocol error (Target.createTarget): Target closed. at Promise (/home/tibdex/Downloads/puppeteer-repro/node_modules/puppeteer/lib/Connection.js:86:56) at new Promise (<anonymous>) at Connection.send (/home/tibdex/Downloads/puppeteer-repro/node_modules/puppeteer/lib/Connection.js:85:12) at Browser._createPageInContext (/home/tibdex/Downloads/puppeteer-repro/node_modules/puppeteer/lib/Browser.js:168:47) at BrowserContext.newPage (/home/tibdex/Downloads/puppeteer-repro/node_modules/puppeteer/lib/Browser.js:260:26) at BrowserContext.<anonymous> (/home/tibdex/Downloads/puppeteer-repro/node_modules/puppeteer/lib/helper.js:136:23) at /home/tibdex/Downloads/puppeteer-repro/index.js:11:30 at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) (node:29943) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:29943) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


But when I run this code instead:

@@ -5,10 +5,8 @@ const puppeteer = require("puppeteer");
dumpio: true,
args: ["--no-sandbox", "--single-process"]
});
- // Create a new incognito browser context.
- const context = await browser.createIncognitoBrowserContext();
- // Create a new page in a pristine context.
- const page = await context.newPage();
+ // Create a new page in the default context.
+ const page = await browser.newPage();
// Do stuff
await page.goto("https://example.com");
})();

it works fine.

Is the incompatibility between the ["--no-sandbox", "--single-process"] arguments and the browser.createIncognitoBrowserContext() method expected?

Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
dadmandcommented, Feb 23, 2020

Use headless and incognito parameter

https://developers.google.com/web/updates/2017/04/headless-chrome


const param_puppeteer = {
  args: [
    "--incognito",
    "--ignore-certificate-errors",
    "--no-sandbox",
    "--disable-setuid-sandbox",
    "--window-size=1920,1080",
    "--disable-accelerated-2d-canvas",
    "--disable-gpu"],
  headless: false
};

const browser = await puppeteer.launch(param_puppeteer);
const context = await browser.createIncognitoBrowserContext();
const page = await context.newPage();
await page.setViewport({ width: 400, height: 800 });
2reactions
aslushnikovcommented, May 31, 2018

@tibdex I see it hits a CHECK in chromium: render_process_host_impl.cc:3752

The --single-process flag is not officially supported/maintained in Chromium; let me see if we can do anything about this particular usecase.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer Hangs In Headless Mode - Stack Overflow
launch({ headless, devtools: true, args: ['--no-sandbox' ] }); const context = await browser.createIncognitoBrowserContext(); const page = await ...
Read more >
Browser.createIncognitoBrowserContext() method - Puppeteer
Browser.createIncognitoBrowserContext() method. Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.
Read more >
pyppeteer - Bountysource
i want to create a incognito page visit some website, but i didn't find out. i notice puppeteer v1.5 has a method called...
Read more >
XSS 401 (Abusing URL parser) - TamilCTF
createIncognitoBrowserContext() const page = await ctx.newPage() try { await page.setCookie({ name: 'flag', value: process.env.
Read more >
mozilla-central: changeset 534188 ...
-We currently use [a fork of Puppeteer] with a small number of tweaks ... "Firefox Browser Page Browser.process should return child_process ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found