Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][debugger] Fix some racy tests #73524

Merged
merged 15 commits into from
Aug 9, 2022
Merged

Conversation

radical
Copy link
Member

@radical radical commented Aug 7, 2022

1. Fix random HotReload test failures

Some of the hot reload tests fail randomly because they call the updated methods too early.
The tests used Thread.Sleep(3000) to wait for the method to get updated, and the proxy
to respond to that. And that's essentially racy.

Instead, wait for the breakpointResolved event, or the scriptParsed events for the methods,
as appropriate.

Fixes #66024
Fixes #72946

2. Fix race in adding/removing event handlers

Use ConcurrentDictionary for event listeners, and notification handlers, since they can be modified
from different threads.

Fixes #69144 .

3. Fix a race condition where the tests start calling methods before the app is ready

Fixes #73528

@ghost
Copy link

ghost commented Aug 7, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Some of the hot reload tests fail randomly because they call the updated methods too early.
The tests used Thread.Sleep(3000) to wait for the method to get updated, and the proxy
to respond to that. And that's essentially racy.

Instead, wait for the breakpointResolved event, or the scriptParsed events for the methods,
as appropriate.

Fixes #66024 .

Author: radical
Assignees: -
Labels:

arch-wasm, area-Debugger-mono, test-failure

Milestone: -

@radical radical requested a review from ilonatommy August 7, 2022 05:22
.. and notification handlers, since they can be modified from different
threads.

Fixes dotnet#69144 .
@radical radical changed the title [wasm][debugger][tests] Fix random HotReload test failures [wasm][debugger] Fix some racy tests Aug 7, 2022
@radical
Copy link
Member Author

radical commented Aug 7, 2022

The debugger test failure is #73528 .

@@ -215,6 +218,15 @@ async Task OnMessage(string method, JObject args, CancellationToken token)
default: _logger.LogInformation(line); break;
}

if (!_gotAppReady && line == "console.debug: #debugger-app-ready#")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

@radical radical added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 9, 2022
- 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 `Inspector`, then 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, we'll emit the old message `console.log: ready` too, just for
consumption by the firefox tests. And this can be fixed property in the
future.
@radical radical removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 9, 2022
@radical radical merged commit 8858001 into dotnet:main Aug 9, 2022
@radical radical deleted the fix-debugger-tests branch August 9, 2022 23:14
@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants