Skip to content

[wasm][debugger] Connection logic for Firefox tests needs improvement #73651

Closed
@radical

Description

@radical
  • With [wasm][debugger] Fix some racy tests #73524, Inspector will wait to get Mono.runtimeReady, and
    console.log: "debug" messages before allowing the tests to run

    • The latter is emitted bye debugger-driver.html, and indicates that the
      app is ready
  • ChromeProvider starts the browser and then waits for a special string
    which indicates that the browser is ready for connections.

  • Firefox doesn't emit anything similar, so it waits for console.log: ready
    message we get from debugger-driver.html.

    • but since we wait for this in FirefoxProvider, when we start the
      Inspector after this, the ready message is already gone, so it will
      never see it.

    • To avoid this, if we change the connection logic to instead:
      a. start the browser
      b. wait till we can connect successfully
      c. and then start the Inspector, it can still be too late if
      the page starts up, and the message is emitted before the Inspector
      was started.

    • A proper fix would be to start the browser but with no url specified.
      And once we establish a connection to it, then send a command to open
      a url.

For now, the PR emits the old message console.log: ready too, just for
consumption by the firefox tests.

We can wait for the browser side to become available by trying the connection
till we get connected, in FirefoxMonoProxy.RunForFirefox:

			bool connected = false;
            DateTime start = DateTime.Now;
            logger.LogInformation($"Trying to connext to ff");
            while (!connected)
            {
                try
                {
                    await browserClient.ConnectAsync("127.0.0.1", portBrowser);
                    connected = true;
                }
                catch (SocketException se)
                {
                    if (se.SocketErrorCode == SocketError.ConnectionRefused && (DateTime.Now - start) > TimeSpan.FromSeconds(30))
                        throw new Exception($"Failed to connect to 127.0.01:{portBrowser} within 30s");
                    logger.LogInformation($"Connection refused. Trying again..");

                    await Task.Delay(500);
                }
            }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions