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.

[BUG] "--no-startup-window" DEFAULT Option might cause hang on Browser.close()

See original GitHub issue

Context:

  • Playwright Version: any version
  • Operating System: Windows 10 Enterprise (64-bit)
  • Browser: Chrome - 91.0.4472.114 (Official Build) (64-bit)
  • Extra: A lot of network restriction - Not allow chrome update.

Code Snippet

import com.microsoft.playwright.*;
import com.microsoft.playwright.BrowserType.LaunchOptions;
import com.microsoft.playwright.options.LoadState;

import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import static com.microsoft.playwright.options.WaitUntilState.DOMCONTENTLOADED;

public class Test {
    static Playwright playWright = null;
    static Browser browser =  null;
    static BrowserContext context =  null;
    static Page page = null;

//  DEBUG=pw:api
//  DEBUG=pw:browser
//  DEBUG=pw:channel
//  DEBUG=pw:*
    public static void main(String args[]) throws Exception {
        try {
            playWright = Playwright.create();
            BrowserType browserType = playWright.chromium();
            LaunchOptions options = new LaunchOptions();
            options.setExecutablePath(Paths.get("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"));
            options.setHeadless(false);
            options.setChromiumSandbox(true);
//            List<String> ignoreDefaultArgs = new ArrayList<>();
//            ignoreDefaultArgs.add("--no-startup-window");  // Caused Issue - Must be Removed from default Option
//            options.setIgnoreDefaultArgs(ignoreDefaultArgs);
            browser = browserType.launch(options);
            context = browser.newContext(
                    new Browser.NewContextOptions()
                            .setViewportSize(800, 600)
            );
            page = context.newPage();
            String url = "http://www.ephung.com/";
            page.navigate(url, new Page.NavigateOptions().setWaitUntil(DOMCONTENTLOADED));
            System.out.println("DONE.");
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            // tear down
            if (page != null) {
                page.close();
                page = null;
            }
            System.out.println("START close Browser " + new Date());
            if (browser != null) {
                browser.close();
                browser = null;
            }
            System.out.println("END close Browser " + new Date());
            if (context != null) {
                context.close();
                context = null;
            }
            if (playWright != null) {
                playWright.close();
                playWright = null;
            }
        }
    }
}

NOTE: Look for the timestamp in log of this code output

            System.out.println("START close Browser " + new Date());
            if (browser != null) {
                browser.close();
                browser = null;
            }
            System.out.println("END close Browser " + new Date());

Describe the bug

One Browser Open look correct - When application Browser.close() Error occur with timeout - kick off kill playwright process image image

When Set to Ignore Argument “–no-startup-windows” - there are 2 browsers open - but Browser.close() closed immediately image

image

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ephung01commented, Dec 20, 2021

It still doesn’t explain why on your screenshot you have a page where you already signed into sharepoint. This can only happen if the browser reuses existing profile with your credentials. Some code is only executed if there is no no-startup-window flag, there is actually more.

When open the browser it’s default homepage to company 365 sharepoint (by default). The auto-login is probably set in the IE Security Zone configuration for autologin with ADFS which explain how when open the browser auto login SharePoint (after redirect to login site and come back to company sharepoint…etc). NOTE: I do not have permission to view IE Setting (all are disabled). I will take a look at the code from the links you’ve provided.

0reactions
mxschmittcommented, May 30, 2022

Closing as part of the triage process since it seemed stale or did not get enough upvotes in the past. Please create a new issue with a detailed reproducible or feature request if you still face issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IE opens flashes and closes immediately when starting it
You may notice that Internet Explorer opens, flashes, and immediately closes when you start Internet Explorer. Cause. The most common causes of ...
Read more >
Restoring 600 tabs at once can make browser completely ...
But if the servers close the channel (because they think the browser has died) then chrome will hang on the channel forever (burning...
Read more >
Common Microsoft Edge Problems, and How to Fix Them
The first obvious solution is to make sure you're running the latest version of Windows 10 or Windows 11 and Microsoft Edge. Microsoft...
Read more >
"Firefox is already running but is not responding" error
Note: If this is a recurring problem, see Firefox hangs when you quit it for ... an error message will appear with the...
Read more >
Chrome is not Working on Windows 11: 8 Rigorous Methods ...
To fix Windows 11 Chrome not working, try starting that browser in its safe mode and disabling antivirus tools as outlined in this...
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