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.

Chromium extension can't establish connection with receiver with Playwright-Java

See original GitHub issue

We have an extension that adds a listener to establish a channel with a cloud service, which works fine when side-loading the extension, or using Playwright-Javascript. With the Java implementation, the extension logs the following to the console:

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

I believe it’s occurring when the extension make this call (or something similar):

.extension.onRequest.addListener((e, t, n) => { t.id === chrome.runtime.id && "?" === e.locked && n({state: this.locked, message: this.lastMessage}) })

The call to .launchPersistentContext is nearly identical to the one that works in Playwright-Javascript:

       Path userDataDir = Paths.get("/tmp/chrome-user" + Integer.toString(instanceCount));
        String extensionPath =
                "./src/test/java/classroom/resources/extensions/crx-" + ClassroomPlaywright.env.getString("customerID");
        List<String> chromeArgs = new ArrayList<>();
        chromeArgs.add("--disable-background-timer-throttling");
        chromeArgs.add("--disable-backgrounding-occluded-windows");
        chromeArgs.add("--disable-renderer-backgrounding");
        chromeArgs.add("--no-sandbox");
        chromeArgs.add("--disable-setuid-sandbox");
        chromeArgs.add("--disable-dev-shm-usage");
        chromeArgs.add("--disable-extensions-except=" + extensionPath);
        chromeArgs.add("--load-extension=" + extensionPath);
        BrowserType.LaunchPersistentContextOptions options = new BrowserType.LaunchPersistentContextOptions();
        options.channel = BrowserChannel.CHROME;
        options.setHeadless(false);
        options.setDevtools(false);
        options.args = chromeArgs;

        studentContext = student.chromium().launchPersistentContext(userDataDir, options);
        studentPage = studentContext.pages().get(0);

I also tried options.setIgnoreAllDefaultArgs and switched off all but the 2 needed for loading the extension, but the error still occurred.

I may be able to provide the extension source, if it will help to debug

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dakLSScommented, Apr 21, 2021

Yes!!! That was a very good observation, indeed! I can’t believe I did that. The bug was all mine. The /dest directory has the extension with the user email poked into the index.js for the extension.

Thank you Yury!!! You may happily close this one out

1reaction
yury-scommented, Apr 20, 2021

Try running both java and nodejs versions with DEBUG=pw:browser environment variable and see what are the actual command line options passed to chrome in each case. If it’s the same binary, launched with the same arguments the behavior should not differ.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't download file with Playwright Chromium or Webkit
Works for Chromium and Firefox. Change outputDirectory variable before running. import com.microsoft.playwright.
Read more >
List of Chromium Command Line Switches - Peter Beverloo
List of Chromium Command Line Switches ; --allow-nacl-socket-api ⊗, Specifies comma-separated list of extension ids or hosts to grant access to TCP/UDP socket ......
Read more >
Use monotonic_time in Playwright Python With Examples ...
Learn how to use monotonic_time function in Playwright Python framework for your next python automation project with LambdaTest Automation Testing Advisor.
Read more >
Inspect Playwright Selectors in Chrome Dev Tools - YouTube
#14 - Inspect Playwright Selectors in Chrome Dev Tools || Playwright with Java.
Read more >
Untitled
Java 1.06 free download, Mey chan 2015, Mazooka marshmallow bazooka uk, ... Millwork jobs in atlanta ga, There is no consensus on global...
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