Skip to content

[rebrowser-playwright] Use directly rebrowser-playwright-core #74

Closed

Description

@regseb

In my project, I have playwright and rebrowser-playwright as dependencies. I have both dependencies, because I use one or the other as needed. But when both have the same version number: rebrowser-playwright doesn't work.

rebrowser-playwright has playwright-core dependency which is replaced by npm:rebrowser-playwright-core@~1.49.1. Due to a bug in npm, the playwright-core dependency overrides rebrowser-playwright-core.


  • package.json

    {
      "name": "testcase",
      "version": "1.0.0",
      "type": "module",
      "dependencies": {
        "playwright": "1.49.1",
        "rebrowser-playwright": "1.49.1"
      }
    }
  • index.js

    import { chromium } from "rebrowser-playwright";
    
    const browser = await chromium.launch();
    const context = await browser.newContext();
    const page = await browser.newPage();
    await page.goto("https://bot-detector.rebrowser.net/");
    
    process.env.REBROWSER_PATCHES_RUNTIME_FIX_MODE = "alwaysIsolated";
    await page.evaluate(() => document.getElementsByClassName("div"));
    delete process.env.REBROWSER_PATCHES_RUNTIME_FIX_MODE;
    
    const detections = await page.locator("#detections-json").inputValue();
    console.log(JSON.parse(detections).find((d) => "mainWorldExecution" === d.type));
    
    await context.close();
    await browser.close();
  1. npm install

  2. node index.js

    {
      type: 'mainWorldExecution',
      rating: 1,
      note: `You've called <code>document.getElementsByClassName()</code> in the main world. Use <a href="https://github.com/rebrowser/rebrowser-patches" target="_blank">rebrowser-patches</a> to run your scripts in an isolated world.`,
      debug: { args: [ 'div' ] },
      msSinceLoad: 29.3
    }

To get around this bug, rebrowser-playwright would have to use rebrowser-playwright-core directly as a dependency (and change the imports).

Activity

  1. nwebson commented on Dec 23, 2024

    @nwebson
    Contributor

    Very nice catch, thanks for reporting this.

  2. rebrowsernet commented on Oct 18, 2026

    @rebrowsernet
    Collaborator

    Confirmed, and it was a silent failure. With playwright and rebrowser-playwright at the same version, npm gives the drop-in the unpatched playwright-core without any error, and the same happens with puppeteer + rebrowser-puppeteer. #132 makes the drop-ins depend on rebrowser-playwright-core / rebrowser-puppeteer-core under their real names. CI now installs each drop-in next to its upstream package and checks that it loads the patched code. Ships in the next release.

  3. rebrowsernet commented on Oct 18, 2026

    @rebrowsernet
    Collaborator

    Released in v1.1.1: rebrowser-puppeteer-core / rebrowser-puppeteer 25.14.100, rebrowser-playwright-core / rebrowser-playwright 1.64.100, and rebrowser-playwright 1.64.100 on PyPI. (npm doesn't allow re-publishing 25.14.0 / 1.64.1, so this fix release uses .100.) rebrowser-puppeteer and rebrowser-playwright now depend on rebrowser-*-core under their real names, so they stay patched next to puppeteer / playwright. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions