<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: v1.30.0</li>
<li>Operating System: Windows</li>
<li>Browser: Chrome</li>
<li>Other info:</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I provided exact source code that allows reproducing the issue locally.</li>
</ul>





<p dir="auto">I am using playwright to control the browser. The tests are written using mocha.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    let resolve: () =&gt; void;
    let reject: (err: unknown) =&gt; void;
    const promise = new Promise&lt;void&gt;((res, rej) =&gt; {
      resolve = res;
      reject = rej;
    });
    const browserProcess = spawn(
      `Start-Process chrome -ArgumentList &quot;--process-per-site --remote-debugging-port=9222&quot;`,
      { shell: 'powershell.exe' }
    );
    browserProcess.on('error', err =&gt; reject(err));
    browserProcess.on('spawn', () =&gt; resolve());

    await promise;
    await new Promise((res) =&gt; setTimeout(res, 10_000));

    browser = await chromium.connectOverCDP('http://127.0.0.1:9222', { timeout: 100_000 /* 100s */ });
    context = browser.contexts()[0];"><pre class="notranslate">    <span class="pl-k">let</span> <span class="pl-s1">resolve</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> <span class="pl-s1">reject</span>: <span class="pl-kos">(</span><span class="pl-s1">err</span>: <span class="pl-smi">unknown</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">promise</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-smi">Promise</span><span class="pl-kos">&lt;</span><span class="pl-smi"><span class="pl-k">void</span></span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">res</span><span class="pl-kos">,</span> <span class="pl-s1">rej</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
      <span class="pl-s1">resolve</span> <span class="pl-c1">=</span> <span class="pl-s1">res</span><span class="pl-kos">;</span>
      <span class="pl-s1">reject</span> <span class="pl-c1">=</span> <span class="pl-s1">rej</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">browserProcess</span> <span class="pl-c1">=</span> <span class="pl-en">spawn</span><span class="pl-kos">(</span>
      <span class="pl-s">`Start-Process chrome -ArgumentList "--process-per-site --remote-debugging-port=9222"`</span><span class="pl-kos">,</span>
      <span class="pl-kos">{</span> <span class="pl-c1">shell</span>: <span class="pl-s">'powershell.exe'</span> <span class="pl-kos">}</span>
    <span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">browserProcess</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'error'</span><span class="pl-kos">,</span> <span class="pl-s1">err</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">reject</span><span class="pl-kos">(</span><span class="pl-s1">err</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">browserProcess</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'spawn'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">await</span> <span class="pl-s1">promise</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-k">new</span> <span class="pl-smi">Promise</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">res</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">setTimeout</span><span class="pl-kos">(</span><span class="pl-s1">res</span><span class="pl-kos">,</span> <span class="pl-c1">10_000</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-s1">browser</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">chromium</span><span class="pl-kos">.</span><span class="pl-en">connectOverCDP</span><span class="pl-kos">(</span><span class="pl-s">'http://127.0.0.1:9222'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">timeout</span>: <span class="pl-c1">100_000</span> <span class="pl-c">/* 100s */</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">context</span> <span class="pl-c1">=</span> <span class="pl-s1">browser</span><span class="pl-kos">.</span><span class="pl-en">contexts</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">The code above</p>
<ul dir="auto">
<li>starts an instance of Chrome using Powershell,</li>
<li>then playwright connects that browser over CDP.</li>
</ul>
<p dir="auto">Justification: A process outside the test code starts a browser, and intend to control that browser instance using playwright. When I <code class="notranslate">launch</code> a browser instance using playwright, then this instance won't be used by that process when it starts navigating to a link.</p>
<p dir="auto">This works when there are no existing instances of Chrome.</p>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>Start a chrome instance normally.</li>
<li>Run the given above.</li>
<li>The connection over CDP is refused.</li>
</ul>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">The connection over CDP is established to the second browser instance opened via the test code.</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">The connection is refused, when there is an existing instance of Chrome running.</p>
<p dir="auto"><strong>Additional note</strong></p>
<p dir="auto">The <code class="notranslate">timeout</code> property in <code class="notranslate">connectOverCDP</code> options does not seem to work. I needed to devise an additional waiting strategy with <code class="notranslate">await new Promise((res) =&gt; setTimeout(res, 10_000));</code>.</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: v 1.30</li>
<li>Operating System: Windows</li>
<li>Browser: Chromium</li>
<li>Other info:</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto">Hi all， when we try to add a trace file to check the details of cases,<br>
we found sometimes the trace file can not record the tests, it happens in opening 2 chromiums in the one case<br>
the trace file is in the attachment, we tried remotely opening it or locally, but both didn't work<br>
and when opening it, it looks like the below, but when debugging cases, all things worked. Could you please help check if is there something potential reasons?<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/12553152/222642075-11f6b160-fe56-4d97-90b9-65d4e1db081c.png"><img src="https://user-images.githubusercontent.com/12553152/222642075-11f6b160-fe56-4d97-90b9-65d4e1db081c.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><a href="https://github.com/microsoft/playwright/files/10878563/trace-1.zip">trace-1.zip</a></p>