Skip to content

Network data collector is asynchronous? #1015

@nvborisenko

Description

@nvborisenko

I am experimenting with network data collector.

Simple code (C#/Selenium):

await using var collector = await bidi.Network.AddDataCollectorAsync([DataType.Response], 10000000);

await using var subscription = await bidi.Network.OnResponseCompletedAsync(async res =>
{
    //await Task.Delay(300); // give a chance for remote-end to materialize data

    Console.WriteLine((await bidi.Network.GetDataAsync(DataType.Response, res.Request.Request)).GetType());
});

await context.NavigateAsync("https://selenium.dev", new() { Wait = ReadinessState.Complete });

Here I do:

  1. Enable data collector for responses
  2. Subscribe on responseCompleted event, and get data for the response as soon as event is raised

Sometimes, I get weird error from remote-end:

no such network data: No collected data for request ED804ADE49D4B69A470EDB66E5C0BE37

But, as soon as I add small delay (300ms) before getting response data, it works smoothly.

PS: this is for Chrome. Firefox works worse: unavailable network data: Network data content for request id 2 and DataType response is unavailable - raising more often.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions