Chrome.ahk icon indicating copy to clipboard operation
Chrome.ahk copied to clipboard

Stuck at sleep loop

Open sergiobachega opened this issue 5 years ago • 3 comments

Sometimes, the return of this.ws.Send on line 233 is so fast that that execution gets line 320 before line 241. ID not exists on responses list, so it get stucked on 242 loop.

232 ID := this.ID += 1 233 this.ws.Send(Chrome.Jxon_Dump({"id": ID 234 , "params": Params ? Params : {} 235 , "method": DomainAndMethod})) 236 237 if !WaitForResponse 238 return 239 240 ; Wait for the response 241 this.responses[ID] := False 242 while !this.responses[ID] 243 Sleep, 50

315 ; Run the callback routine 316 fnCallback := this.fnCallback 317 if (newData := %fnCallback%(data)) 318 data := newData 319 320 if this.responses.HasKey(data.ID) 321 this.responses[data.ID] := data

The solution is to transfer "this.responses[ID] := False" to before "this.ws.Send"

232 ID := this.ID += 1 233 if WaitForResponse 234 this.responses[ID] := False 235 this.ws.Send(Chrome.Jxon_Dump({"id": ID 236 , "params": Params ? Params : {} 237 , "method": DomainAndMethod})) 238 239 if !WaitForResponse 240 return 241 ; Wait for the response 242 while !this.responses[ID] 243 Sleep, 50

sergiobachega avatar Sep 03 '19 21:09 sergiobachega

I'm also struggling with this. Any time I execute a call to the page outside my origional connection call, i end up in an endless loop.

However, I tried the above fix, and that didn't work.

This is most noteable when I use AHK to evaluate JS on the page or issue a Call to change the url

such as: navigator(url) { global wb ;bring in our PageInst

wb.Call("Page.navigate", {"url": "" . url . ""}) ; navigate to new URL and we get stuck in a sleep loop.

StavenCross avatar Jan 02 '20 17:01 StavenCross

Has anyone found solution for this? It seems like it only goes to sleep loop if chrome is left untouched. So it probably loses connection to chrome instance. I tried fixing it but it just goes to loop after couple of minutes.

Is there a way at least to catch it and reload or something simillar?

J-Filip avatar May 06 '21 17:05 J-Filip

is there any news about this issue?

gabrigrillo avatar Apr 22 '22 13:04 gabrigrillo