<p dir="auto">I am working on a script against an app which performs backend queries via graphql. Request path is the same, only body in POST requests are different. When I manually visit one section of the site which displays various data I can clearly see multiple graphql queries with different content. However when I run it in a playwright script only first one issued and responded, rest of them do not fire up. This issue happens in puppeteer as well, but not selenium which handles it correctly.</p>
<p dir="auto">For example when I visit page manually 3 requests are issued (also via selenium):</p>
<ul dir="auto">
<li>graphql1</li>
<li>graphql2</li>
<li>graphql3</li>
</ul>
<p dir="auto">In case of Playwright and Puppeteer only first one is issued, <strong>graphql2</strong> and <strong>graphql3</strong> are not visible in devtools (it's also noticeable on page which lacks data)</p>
<p dir="auto">Question is - is there a special way to handle such scenarios in Playwright? Is there some magic in the background that blocks requests considered duplicates and can be turned off?</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.32]</li>
<li>Operating System: [macOS 13.2.1]</li>
<li>Browser: [Chromium]</li>
<li>node: v18.12.1</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"><strong>Link to the GitHub repository with the repro</strong></p>
<p dir="auto"><a href="https://github.com/skvale/playwright-repro">https://github.com/skvale/playwright-repro</a></p>
<p dir="auto">or</p>
<p dir="auto"><strong>Config file</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// playwright.config.ts
/** @type {import('@playwright/test').Config} */
const config = {
  updateSnapshots: 'missing',
  timeout: 20000,
  webServer: {
    command: 'pnpm build &amp;&amp; pnpm serve',
    url: 'http://localhost:3003/',
    reuseExistingServer: false,
    timeout: 20000,
  },
  workers: 8,
  retries: process.env.CI ? 5 : 0,
  projects: [
    {
      name: 'test',
      use: {
        javaScriptEnabled: true,
      },
    },
  ],
  use: {
    baseURL: 'http://localhost:3003/',
    screenshot: 'only-on-failure',
    trace: 'retain-on-failure',
    launchOptions: {
      ignoreDefaultArgs: ['--hide-scrollbars'],
    },
  },
};
export default config;"><pre class="notranslate"><span class="pl-c">// playwright.config.ts</span>
<span class="pl-c">/** <span class="pl-k">@type</span> {import('@playwright/test').Config} */</span>
<span class="pl-k">const</span> <span class="pl-s1">config</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">updateSnapshots</span>: <span class="pl-s">'missing'</span><span class="pl-kos">,</span>
  <span class="pl-c1">timeout</span>: <span class="pl-c1">20000</span><span class="pl-kos">,</span>
  <span class="pl-c1">webServer</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">command</span>: <span class="pl-s">'pnpm build &amp;&amp; pnpm serve'</span><span class="pl-kos">,</span>
    <span class="pl-c1">url</span>: <span class="pl-s">'http://localhost:3003/'</span><span class="pl-kos">,</span>
    <span class="pl-c1">reuseExistingServer</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-c1">timeout</span>: <span class="pl-c1">20000</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c1">workers</span>: <span class="pl-c1">8</span><span class="pl-kos">,</span>
  <span class="pl-c1">retries</span>: <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">CI</span> ? <span class="pl-c1">5</span> : <span class="pl-c1">0</span><span class="pl-kos">,</span>
  <span class="pl-c1">projects</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'test'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">javaScriptEnabled</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">baseURL</span>: <span class="pl-s">'http://localhost:3003/'</span><span class="pl-kos">,</span>
    <span class="pl-c1">screenshot</span>: <span class="pl-s">'only-on-failure'</span><span class="pl-kos">,</span>
    <span class="pl-c1">trace</span>: <span class="pl-s">'retain-on-failure'</span><span class="pl-kos">,</span>
    <span class="pl-c1">launchOptions</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">ignoreDefaultArgs</span>: <span class="pl-kos">[</span><span class="pl-s">'--hide-scrollbars'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</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">export</span> <span class="pl-k">default</span> <span class="pl-s1">config</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import {expect, test} from '@playwright/test';

test.describe.parallel('Site', () =&gt; {
  test('shows home content', async ({page}) =&gt; {
    await page.goto('/');
    await expect(page.getByText('@2023 All rights reserved')).toBeVisible();
  });
});"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">expect</span><span class="pl-kos">,</span> <span class="pl-s1">test</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>

<span class="pl-s1">test</span><span class="pl-kos">.</span><span class="pl-c1">describe</span><span class="pl-kos">.</span><span class="pl-en">parallel</span><span class="pl-kos">(</span><span class="pl-s">'Site'</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-kos">{</span>
  <span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'shows home content'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span>page<span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s">'/'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByText</span><span class="pl-kos">(</span><span class="pl-s">'@2023 All rights reserved'</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBeVisible</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>pnpm install</li>
<li>pnpm test</li>
</ul>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto"><code class="notranslate">playwright test test.playwright.test.ts --ui</code> loads Playwright in UI mode</p>
<p dir="auto"><strong>Actual</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; playwright test test.playwright.test.ts &quot;--ui&quot;

/Users/me/project/node_modules/.pnpm/@playwright+test@1.32.0/node_modules/@playwright/test/lib/runner/uiMode.js:159
    this._page.mainFrame().evaluateExpression(dispatchFuncSource, true, message).catch(e =&gt; this._originalStderr(String(e)));
               ^

TypeError: Cannot read properties of undefined (reading 'mainFrame')
    at UIMode._dispatchEvent (/Users/me/project/node_modules/.pnpm/@playwright+test@1.32.0/node_modules/@playwright/test/lib/runner/uiMode.js:159:16)
    at Timeout._onTimeout (/Users/me/project/node_modules/.pnpm/@playwright+test@1.32.0/node_modules/@playwright/test/lib/runner/uiMode.js:69:14)
    at listOnTimeout (node:internal/timers:564:17)
    at processTimers (node:internal/timers:507:7)"><pre class="notranslate"><code class="notranslate">&gt; playwright test test.playwright.test.ts "--ui"

/Users/me/project/node_modules/.pnpm/@playwright+test@1.32.0/node_modules/@playwright/test/lib/runner/uiMode.js:159
    this._page.mainFrame().evaluateExpression(dispatchFuncSource, true, message).catch(e =&gt; this._originalStderr(String(e)));
               ^

TypeError: Cannot read properties of undefined (reading 'mainFrame')
    at UIMode._dispatchEvent (/Users/me/project/node_modules/.pnpm/@playwright+test@1.32.0/node_modules/@playwright/test/lib/runner/uiMode.js:159:16)
    at Timeout._onTimeout (/Users/me/project/node_modules/.pnpm/@playwright+test@1.32.0/node_modules/@playwright/test/lib/runner/uiMode.js:69:14)
    at listOnTimeout (node:internal/timers:564:17)
    at processTimers (node:internal/timers:507:7)
</code></pre></div>
<h3 dir="auto">Additional info:</h3>
<p dir="auto">Link to the line that was failing<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/microsoft/playwright/blob/d10fac4f6a0dfeb3577eec6cdff7ec3bdc843c01/packages/playwright-test/src/runner/uiMode.ts#L152">playwright/packages/playwright-test/src/runner/uiMode.ts</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 152
      in
      <a data-pjax="true" class="commit-tease-sha" href="/microsoft/playwright/commit/d10fac4f6a0dfeb3577eec6cdff7ec3bdc843c01">d10fac4</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L152" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="152"></td>
          <td id="LC152" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">_page</span><span class="pl-kos">.</span><span class="pl-en">mainFrame</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">evaluateExpression</span><span class="pl-kos">(</span><span class="pl-s1">dispatchFuncSource</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">,</span> <span class="pl-s1">message</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">catch</span><span class="pl-kos">(</span><span class="pl-s1">e</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">_originalStderr</span><span class="pl-kos">(</span><span class="pl-smi">String</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Wrapping it in an <code class="notranslate">if (this._page)</code> seems to work</p>
<p dir="auto">Message looks like this <code class="notranslate">{ message: { method: 'listChanged' } }</code>, perhaps the output from the build command is triggering events before the page is initialized</p>