hardkoded/puppeteer-sharp

ClickAsync Timeout

Closed this issue · 12 comments

I've a page with

page.ClickAsync("#__button12" );

The script runs ok but it takes very long time to complete.
So i'm getting this error:

immagine

Is there a way to avoid timeout?

That's odd. That's the browser not responding. If you run that in headful mode, do you see the browser getting stuck? high CPU usage?

in headful mode runs without problems

Other error in headless mode

immagine

Other error in headless mode

immagine

It looks like an error on a Console event listener you have?

It looks like an error on a Console event listener you have?

I'm using always the same input and yes I have a Page_Console event handler but why sometimes runs ok and sometimes not? Even with the same input?

immagine

It looks like an error on a Console event listener you have?

I'm using always the same input and yes I have a Page_Console event handler but why sometimes runs ok and sometimes not? Even with the same input?

immagine

Do you have a dictionary where you are collecting info? Maybe a race condition? Console events don't come always at the same time.

Can you also check if, by removing the event, the click stops getting stuck? Maybe is the listener that's breaking the flow.

Oh yes I have list and dict
.. how can avoid events not in same time?

void Page_Console(object? sender, ConsoleEventArgs e)
{
     if (e.Message.Type == ConsoleType.Log)
    {
        if (e.Message.Text.StartsWith("scene._scene.traverse.end"))
        {
            structMode = false;
            return;
       }

        if (structMode)
        {
            if (rootNode==null)
            {
                rootNode= new NodeObj();
                rootNode = Newtonsoft.Json.JsonConvert.DeserializeObject<NodeObj>(e.Message.Text);
                lastNode= rootNode; 
            } else
            {
                NodeObj thisNode = Newtonsoft.Json.JsonConvert.DeserializeObject<NodeObj>(e.Message.Text);
                NodeObj pNode = NodeList[thisNode.ParentId];
                pNode.Items.Add(thisNode);
                lastNode = thisNode;

            }

            if (MeshList.ContainsKey(lastNode.Id))
            {
                lastNode.Mesh= MeshList[lastNode.Id];
            }
            JSObjectIndex = JSObjectIndex + 1;
            Console.WriteLine("Traversing scene " + JSObjectIndex.ToString() + "/" + JSObjectCount.ToString());
            PushNode(lastNode);
            return;
        }

        if (e.Message.Text.StartsWith("Processing file") && e.Message.Text.Contains("finished"))
        {
            loaded3D = true;
            return;
        }
        if (e.Message.Text.StartsWith("scene._scene.traverse.start"))
        {
            structMode = true;
            JSObjectCount = System.Convert.ToInt64( e.Message.Text.Replace("scene._scene.traverse.start:", ""));
            return;

        }


        if (e.Message.Text.StartsWith("{\"AAXX\":\"C@MER@\""))
        {
            CameraObj deserializedCam = Newtonsoft.Json.JsonConvert.DeserializeObject<CameraObj>(e.Message.Text);
            CameraList.Add(deserializedCam);
            Console.WriteLine("Lettura Camera " + deserializedCam.Name);
        }
        if (e.Message.Text.StartsWith("{\"AAXX\":\"ME$H\""))
        {
    

            MeshObj deserializedProduct = Newtonsoft.Json.JsonConvert.DeserializeObject<MeshObj>(e.Message.Text);
            MeshList.Add(deserializedProduct.Id,deserializedProduct);
            Console.WriteLine("Lettura Mesh " + deserializedProduct.PROG);

        }

    }


}

.. how can avoid events not in same time?

You can't trust the order in which the browser sends messages.

Same code in debug IDE (VS2022) runs wothout errors,
and same code in release mode (SOMETIMES ) works (SOMETIMES also with headless=true)

after some changes in code... remains

immagine

I'm using c# project to read from console.log objects that are serialized in the click event of an html button.

How can I increase this timeout ?

immagine

You can increase it by setting the ProtocolTimeout