<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: 1.32.3 but also reproduced on 1.30.2</li>
<li>Operating System:Windows</li>
<li>Browser: Chrome</li>
<li>Other info: Node: 18.12.1</li>
</ul>
<h3 dir="auto">Source code</h3>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="await this.page.waitForLoadState(&quot;load&quot;, { timeout: 10 * 1000 });
      await expect(this.projectCard).toHaveScreenshot({
        mask: [
          this.projectNameInput,
          this.footerRegisterLabel,
          this.projectTabNumberInput,
        ],
        maxDiffPixelRatio: 0.01,
        timeout: 5 * 1000,"><pre class="notranslate"><span class="pl-k">await</span> <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">waitForLoadState</span><span class="pl-kos">(</span><span class="pl-s">"load"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">timeout</span>: <span class="pl-c1">10</span> <span class="pl-c1">*</span> <span class="pl-c1">1000</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-en">expect</span><span class="pl-kos">(</span><span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">projectCard</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">toHaveScreenshot</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
        <span class="pl-c1">mask</span>: <span class="pl-kos">[</span>
          <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">projectNameInput</span><span class="pl-kos">,</span>
          <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">footerRegisterLabel</span><span class="pl-kos">,</span>
          <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">projectTabNumberInput</span><span class="pl-kos">,</span>
        <span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-c1">maxDiffPixelRatio</span>: <span class="pl-c1">0.01</span><span class="pl-kos">,</span>
        <span class="pl-c1">timeout</span>: <span class="pl-c1">5</span> <span class="pl-c1">*</span> <span class="pl-c1">1000</span><span class="pl-kos">,</span></pre></div>
<p dir="auto"><strong>Config file</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const config: PlaywrightTestConfig = {
  testDir: &quot;./tests&quot;,
  /* Maximum time one test can run for. */
  timeout: 5 * 60 * 1000,
  expect: {
    /**
     * Maximum time expect() should wait for the condition to be met.
     * For example in `await expect(locator).toHaveText();`
     */
    timeout: 5000,
  },
  /* Run tests in files in parallel */
  fullyParallel: true,
  /* Fail the build on CI if you accidentally left test.only in the source code. */
  forbidOnly: !!process.env.CI,
  /* Retry on CI only */
  // retries: process.env.CI ? 2 : 0,
  // /* Opt out of parallel tests on CI. */
  // workers: process.env.CI ? 1 : undefined,
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  reporter: [
    [&quot;list&quot;],
    [&quot;html&quot;, { outputFolder: &quot;./outputs&quot;, open: &quot;never&quot; }],
    [&quot;junit&quot;, { outputFile: &quot;./outputs/results.xml&quot; }],
  ],
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
    actionTimeout: 10 * 1000,
    headless: true,
    screenshot: &quot;only-on-failure&quot;,
    video: &quot;retain-on-failure&quot;,
    viewport: { width: 1920, height: 1080 },
    /* Base URL to use in actions like `await page.goto('/')`. */
    // baseURL: 'http://localhost:3000',

    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    trace: &quot;retain-on-failure&quot;,
  },
"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">config</span>: <span class="pl-smi">PlaywrightTestConfig</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">testDir</span>: <span class="pl-s">"./tests"</span><span class="pl-kos">,</span>
  <span class="pl-c">/* Maximum time one test can run for. */</span>
  <span class="pl-c1">timeout</span>: <span class="pl-c1">5</span> <span class="pl-c1">*</span> <span class="pl-c1">60</span> <span class="pl-c1">*</span> <span class="pl-c1">1000</span><span class="pl-kos">,</span>
  <span class="pl-c1">expect</span>: <span class="pl-kos">{</span>
    <span class="pl-c">/**</span>
<span class="pl-c">     * Maximum time expect() should wait for the condition to be met.</span>
<span class="pl-c">     * For example in `await expect(locator).toHaveText();`</span>
<span class="pl-c">     */</span>
    <span class="pl-c1">timeout</span>: <span class="pl-c1">5000</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c">/* Run tests in files in parallel */</span>
  <span class="pl-c1">fullyParallel</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
  <span class="pl-c">/* Fail the build on CI if you accidentally left test.only in the source code. */</span>
  <span class="pl-c1">forbidOnly</span>: <span class="pl-c1">!</span><span class="pl-c1">!</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-kos">,</span>
  <span class="pl-c">/* Retry on CI only */</span>
  <span class="pl-c">// retries: process.env.CI ? 2 : 0,</span>
  <span class="pl-c">// /* Opt out of parallel tests on CI. */</span>
  <span class="pl-c">// workers: process.env.CI ? 1 : undefined,</span>
  <span class="pl-c">/* Reporter to use. See https://playwright.dev/docs/test-reporters */</span>
  <span class="pl-c1">reporter</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">[</span><span class="pl-s">"list"</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">[</span><span class="pl-s">"html"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">outputFolder</span>: <span class="pl-s">"./outputs"</span><span class="pl-kos">,</span> <span class="pl-c1">open</span>: <span class="pl-s">"never"</span> <span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">[</span><span class="pl-s">"junit"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">outputFile</span>: <span class="pl-s">"./outputs/results.xml"</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-c">/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */</span>
  <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
    <span class="pl-c">/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */</span>
    <span class="pl-c1">actionTimeout</span>: <span class="pl-c1">10</span> <span class="pl-c1">*</span> <span class="pl-c1">1000</span><span class="pl-kos">,</span>
    <span class="pl-c1">headless</span>: <span class="pl-c1">true</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">video</span>: <span class="pl-s">"retain-on-failure"</span><span class="pl-kos">,</span>
    <span class="pl-c1">viewport</span>: <span class="pl-kos">{</span> <span class="pl-c1">width</span>: <span class="pl-c1">1920</span><span class="pl-kos">,</span> <span class="pl-c1">height</span>: <span class="pl-c1">1080</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c">/* Base URL to use in actions like `await page.goto('/')`. */</span>
    <span class="pl-c">// baseURL: 'http://localhost:3000',</span>

    <span class="pl-c">/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */</span>
    <span class="pl-c1">trace</span>: <span class="pl-s">"retain-on-failure"</span><span class="pl-kos">,</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span></pre></div>
<p dir="auto"><strong>Expected</strong><br>
I expect to "expect(someLocator).toHaveScreenshot" to retry assertion for fail/success until it timeout is reached.</p>
<p dir="auto"><strong>Actual</strong><br>
Both global timeout (set in config), but also direct set as toHaveScreenshot(timeout: //will be ignored) are ignored as assertion fails &lt; 1000ms<br>
Plase checkout that picture. It is clear that 5000 as timeout has been passed, but also visible that assertion has failed after only 900ms<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/29520131/233837386-54ec879d-5185-4fec-8c25-89df49939c4b.png"><img src="https://user-images.githubusercontent.com/29520131/233837386-54ec879d-5185-4fec-8c25-89df49939c4b.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: "1.29.2"</li>
<li>Operating System: Linux/AMD64</li>
<li>Browser: Chromium</li>
<li>java.version: '11.0.17'</li>
<li>Selenium: Selenium grid 4 with image version:4.8.1-20230221</li>
</ul>
<p dir="auto">Code snippet:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const options: LaunchOptions = {
  args: ['--remote-allow-origins=*'],
  headless: false,
  slowMo: 100,
};

BeforeAll(async () =&gt; {
  console.log('starting browser');
  switch (process.env.BROWSER) {
    case 'firefox':
      global.browser = await firefox.launch(options);
      break;
    case 'webkit':
      global.browser = await webkit.launch(options);
      break;
    default:
      global.browser = await chromium.launch(options);
  }
});

AfterAll(async () =&gt; {
  await global.browser.close();
  console.log('starting browser');
});

Before(async () =&gt; {
  global.context = await global.browser.newContext({ ignoreHTTPSErrors: true });
  global.page = await global.context.newPage();

  const git = simpleGit();
  const branchName = (await git.branch()).current.trim();
  if (branchName !== 'main') {
    console.log(`[E2E] Running regression on feature branch &quot;${branchName}&quot;`);
    await global.page.goto(global.BASE_URL + '/search/form.uri?display=basic#basic');
    await global.page.evaluate('window.microUiOverrides?.clear();');

    const microUis = [

        &quot;List of microUIS here&quot;
    ];

    await Promise.all(
      microUis.map((microUi) =&gt; {
        global.page.evaluate(`window.microUiOverrides?.useBranch('${microUi}','${branchName}')`);
      }),
    );
  }
});

After(async function (scenario) {
  if (scenario.result!.status === Status.FAILED) {
    const buffer = await global.page.screenshot({
      path: `../../dist/apps/e2e/${scenario.gherkinDocument.uri}-${scenario.pickle.name}.png`,
      fullPage: true,
    });
    await this.attach(buffer, 'image/png');
  }
  await global.page.close();
  await global.context.close();
});"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">options</span>: <span class="pl-smi">LaunchOptions</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">args</span>: <span class="pl-kos">[</span><span class="pl-s">'--remote-allow-origins=*'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-c1">headless</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
  <span class="pl-c1">slowMo</span>: <span class="pl-c1">100</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-smi">BeforeAll</span><span class="pl-kos">(</span><span class="pl-k">async</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-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'starting browser'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">switch</span> <span class="pl-kos">(</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">BROWSER</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">case</span> <span class="pl-s">'firefox'</span>:
      <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">browser</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">firefox</span><span class="pl-kos">.</span><span class="pl-en">launch</span><span class="pl-kos">(</span><span class="pl-s1">options</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
    <span class="pl-k">case</span> <span class="pl-s">'webkit'</span>:
      <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">browser</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">webkit</span><span class="pl-kos">.</span><span class="pl-en">launch</span><span class="pl-kos">(</span><span class="pl-s1">options</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">break</span><span class="pl-kos">;</span>
    <span class="pl-k">default</span>:
      <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">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">launch</span><span class="pl-kos">(</span><span class="pl-s1">options</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-smi">AfterAll</span><span class="pl-kos">(</span><span class="pl-k">async</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-k">await</span> <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">browser</span><span class="pl-kos">.</span><span class="pl-en">close</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'starting browser'</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-smi">Before</span><span class="pl-kos">(</span><span class="pl-k">async</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-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">context</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">browser</span><span class="pl-kos">.</span><span class="pl-en">newContext</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">ignoreHTTPSErrors</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-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">page</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">context</span><span class="pl-kos">.</span><span class="pl-en">newPage</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">git</span> <span class="pl-c1">=</span> <span class="pl-en">simpleGit</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">branchName</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-k">await</span> <span class="pl-s1">git</span><span class="pl-kos">.</span><span class="pl-en">branch</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">current</span><span class="pl-kos">.</span><span class="pl-en">trim</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">branchName</span> <span class="pl-c1">!==</span> <span class="pl-s">'main'</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">`[E2E] Running regression on feature branch "<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">branchName</span><span class="pl-kos">}</span></span>"`</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">page</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">BASE_URL</span> <span class="pl-c1">+</span> <span class="pl-s">'/search/form.uri?display=basic#basic'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">page</span><span class="pl-kos">.</span><span class="pl-en">evaluate</span><span class="pl-kos">(</span><span class="pl-s">'window.microUiOverrides?.clear();'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">const</span> <span class="pl-s1">microUis</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span>

        <span class="pl-s">"List of microUIS here"</span>
    <span class="pl-kos">]</span><span class="pl-kos">;</span>

    <span class="pl-k">await</span> <span class="pl-smi">Promise</span><span class="pl-kos">.</span><span class="pl-en">all</span><span class="pl-kos">(</span>
      <span class="pl-s1">microUis</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">microUi</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">page</span><span class="pl-kos">.</span><span class="pl-en">evaluate</span><span class="pl-kos">(</span><span class="pl-s">`window.microUiOverrides?.useBranch('<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">microUi</span><span class="pl-kos">}</span></span>','<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">branchName</span><span class="pl-kos">}</span></span>')`</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><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-smi">After</span><span class="pl-kos">(</span><span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">scenario</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">scenario</span><span class="pl-kos">.</span><span class="pl-c1">result</span><span class="pl-c1">!</span><span class="pl-kos">.</span><span class="pl-c1">status</span> <span class="pl-c1">===</span> <span class="pl-smi">Status</span><span class="pl-kos">.</span><span class="pl-c1">FAILED</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">buffer</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">global</span><span class="pl-kos">.</span><span class="pl-c1">page</span><span class="pl-kos">.</span><span class="pl-en">screenshot</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
      <span class="pl-c1">path</span>: <span class="pl-s">`../../dist/apps/e2e/<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">scenario</span><span class="pl-kos">.</span><span class="pl-c1">gherkinDocument</span><span class="pl-kos">.</span><span class="pl-c1">uri</span><span class="pl-kos">}</span></span>-<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">scenario</span><span class="pl-kos">.</span><span class="pl-c1">pickle</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">}</span></span>.png`</span><span class="pl-kos">,</span>
      <span class="pl-c1">fullPage</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-k">await</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">attach</span><span class="pl-kos">(</span><span class="pl-s1">buffer</span><span class="pl-kos">,</span> <span class="pl-s">'image/png'</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">global</span><span class="pl-kos">.</span><span class="pl-c1">page</span><span class="pl-kos">.</span><span class="pl-en">close</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">global</span><span class="pl-kos">.</span><span class="pl-c1">context</span><span class="pl-kos">.</span><span class="pl-en">close</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>We are running the playwright testes on selenium grid 4 on EKS and when we run the tests via jenkins we get the below error:</li>
</ul>
<p dir="auto">Jenkins error:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
......2023-03-22T13:30:54.390Z pw:browser &lt;ws disconnected&gt; wss://&lt;selenium-url&gt;/session/2c5f661ddb68a0a4e3b9dc4afd4ce612/se/cdp code=1005 reason=
F---2023-03-22T13:30:54.407Z pw:browser &lt;selenium&gt; disconnecting from sessionId=2c5f661ddb68a0a4e3b9dc4afd4ce612
----FF----------FF---2023-03-22T13:30:54.515Z pw:browser &lt;error disconnecting from selenium&gt;: Error: fetch failed: server returned code 404. URL: https://&lt;selenium-url&gt;/wd/hub/session/2c5f661ddb68a0a4e3b9dc4afd4ce612
2023-03-22T13:30:54.529Z pw:browser &lt;selenium&gt; disconnected from sessionId=2c5f661ddb68a0a4e3b9dc4afd4ce612
FF---FF---FF---FF---FF---FF--FF--FF------FF------FF---------------FF---------------Fstarting browser
.......2023-03-22T13:30:58.645Z pw:browser &lt;ws disconnecting&gt; wss://&lt;selenium-url&gt;/session/a07f6e717605940d092e0975b64de72c/se/cdp
2023-03-22T13:30:58.683Z pw:browser &lt;ws disconnected&gt; wss://&lt;selenium-url&gt;/session/a07f6e717605940d092e0975b64de72c/se/cdp code=1005 reason=
2023-03-22T13:30:58.691Z pw:browser &lt;selenium&gt; disconnecting from sessionId=a07f6e717605940d092e0975b64de72c
2023-03-22T13:30:58.743Z pw:browser &lt;error disconnecting from selenium&gt;: Error: fetch failed: server returned code 404. URL: https://&lt;selenium-url&gt;/wd/hub/session/a07f6e717605940d092e0975b64de72c
2023-03-22T13:30:58.743Z pw:browser &lt;selenium&gt; disconnected from sessionId=a07f6e717605940d092e0975b64de72c


Before # ../../shared-e2e/support/hooks.ts:26
        browser.newContext: Target page, context or browser has been closed
            at async World.&lt;anonymous&gt; (/home/jenkins/agent/workspace/e2e-selenium-test-sample/shared-e2e/support/hooks.ts:27:22)


After # ../../shared-e2e/support/hooks.ts:59
        page.screenshot: Target page, context or browser has been closed
            at World.&lt;anonymous&gt; (/home/jenkins/agent/workspace/e2e-selenium-test-sample/shared-e2e/support/hooks.ts:61:42)"><pre class="notranslate">......2023-03-22T13:30:54.390Z pw:browser <span class="pl-k">&lt;</span>ws disconnected<span class="pl-k">&gt;</span> wss://<span class="pl-k">&lt;</span>selenium-url<span class="pl-k">&gt;</span>/session/2c5f661ddb68a0a4e3b9dc4afd4ce612/se/cdp code=1005 reason=
F---2023-03-22T13:30:54.407Z pw:browser <span class="pl-k">&lt;</span>selenium<span class="pl-k">&gt;</span> disconnecting from sessionId=2c5f661ddb68a0a4e3b9dc4afd4ce612
----FF----------FF---2023-03-22T13:30:54.515Z pw:browser <span class="pl-k">&lt;</span>error disconnecting from selenium<span class="pl-k">&gt;</span>: Error: fetch failed: server returned code 404. URL: https://<span class="pl-k">&lt;</span>selenium-url<span class="pl-k">&gt;</span>/wd/hub/session/2c5f661ddb68a0a4e3b9dc4afd4ce612
2023-03-22T13:30:54.529Z pw:browser <span class="pl-k">&lt;</span>selenium<span class="pl-k">&gt;</span> disconnected from sessionId=2c5f661ddb68a0a4e3b9dc4afd4ce612
FF---FF---FF---FF---FF---FF--FF--FF------FF------FF---------------FF---------------Fstarting browser
.......2023-03-22T13:30:58.645Z pw:browser <span class="pl-k">&lt;</span>ws disconnecting<span class="pl-k">&gt;</span> wss://<span class="pl-k">&lt;</span>selenium-url<span class="pl-k">&gt;</span>/session/a07f6e717605940d092e0975b64de72c/se/cdp
2023-03-22T13:30:58.683Z pw:browser <span class="pl-k">&lt;</span>ws disconnected<span class="pl-k">&gt;</span> wss://<span class="pl-k">&lt;</span>selenium-url<span class="pl-k">&gt;</span>/session/a07f6e717605940d092e0975b64de72c/se/cdp code=1005 reason=
2023-03-22T13:30:58.691Z pw:browser <span class="pl-k">&lt;</span>selenium<span class="pl-k">&gt;</span> disconnecting from sessionId=a07f6e717605940d092e0975b64de72c
2023-03-22T13:30:58.743Z pw:browser <span class="pl-k">&lt;</span>error disconnecting from selenium<span class="pl-k">&gt;</span>: Error: fetch failed: server returned code 404. URL: https://<span class="pl-k">&lt;</span>selenium-url<span class="pl-k">&gt;</span>/wd/hub/session/a07f6e717605940d092e0975b64de72c
2023-03-22T13:30:58.743Z pw:browser <span class="pl-k">&lt;</span>selenium<span class="pl-k">&gt;</span> disconnected from sessionId=a07f6e717605940d092e0975b64de72c


Before <span class="pl-c"><span class="pl-c">#</span> ../../shared-e2e/support/hooks.ts:26</span>
        browser.newContext: Target page, context or browser has been closed
            at async World.<span class="pl-k">&lt;</span>anonymous<span class="pl-k">&gt;</span> (/home/jenkins/agent/workspace/e2e-selenium-test-sample/shared-e2e/support/hooks.ts:27:22)


After <span class="pl-c"><span class="pl-c">#</span> ../../shared-e2e/support/hooks.ts:59</span>
        page.screenshot: Target page, context or browser has been closed
            at World.<span class="pl-k">&lt;</span>anonymous<span class="pl-k">&gt;</span> (/home/jenkins/agent/workspace/e2e-selenium-test-sample/shared-e2e/support/hooks.ts:61:42)</pre></div>
<p dir="auto">Selenium hub error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:222)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:229)
	... 9 more
13:27:06.679 INFO [GridModel.release] - Releasing slot for session id e4fc90b85375366c41f665e96db248fe
13:27:06.679 INFO [LocalSessionMap.lambda$new$0] - Deleted session from local Session Map, Id: e4fc90b85375366c41f665e96db248fe
13:27:07.258 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 499120264588998c705a4b8d05e1df5f 
13:27:07.497 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.8.1', revision: '8ebccac989'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.228-132.418.amzn2.x86_64', java.version: '11.0.17'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:239)
	at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:222)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:229)
	... 9 more"><pre class="notranslate"><code class="notranslate">	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:222)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:229)
	... 9 more
13:27:06.679 INFO [GridModel.release] - Releasing slot for session id e4fc90b85375366c41f665e96db248fe
13:27:06.679 INFO [LocalSessionMap.lambda$new$0] - Deleted session from local Session Map, Id: e4fc90b85375366c41f665e96db248fe
13:27:07.258 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 499120264588998c705a4b8d05e1df5f 
13:27:07.497 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.8.1', revision: '8ebccac989'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.228-132.418.amzn2.x86_64', java.version: '11.0.17'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:239)
	at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:222)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:229)
	... 9 more
</code></pre></div>
<p dir="auto"><strong>Expected</strong></p>
<ul dir="auto">
<li>All tests should run without above error.</li>
</ul>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">Failing with above mentioned error</p>
<p dir="auto"><strong>NOTE</strong><br>
If we run the exact same suite on selenium grid running on EC2 instance, it works fine.</p>
<p dir="auto"><strong>Solutions tried</strong></p>
<ul dir="auto">
<li>We have already implemented suggestions from here <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1488598072" data-permission-text="Title is private" data-url="https://github.com/SeleniumHQ/selenium/issues/11408" data-hovercard-type="issue" data-hovercard-url="/SeleniumHQ/selenium/issues/11408/hovercard?comment_id=1345401948&amp;comment_type=issue_comment" href="https://github.com/SeleniumHQ/selenium/issues/11408#issuecomment-1345401948">SeleniumHQ/selenium#11408 (comment)</a></li>
<li>Tried by increasing session timeout value for sessionqueue and chrome node.</li>
<li>Tried with selenium hub: 4.5.0 as well.</li>
</ul>