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

More execution contexts related to one frame #1

Open
tomaskrupka opened this issue Dec 14, 2021 · 2 comments
Open

More execution contexts related to one frame #1

tomaskrupka opened this issue Dec 14, 2021 · 2 comments
Assignees

Comments

@tomaskrupka
Copy link
Owner

CdtrChromeClient.MainContext crashes on NullReferenceException.

 Failed to GetBackendNodeId: System.AggregateException: One or more errors occurred. (Runtime.evaluate: Cannot find context with specified id)
 ---> BaristaLabs.ChromeDevTools.Runtime.CommandResponseException: Runtime.evaluate: Cannot find context with specified id
 at BaristaLabs.ChromeDevTools.Runtime.ChromeSession.SendCommand(String commandName, JToken params, CancellationToken cancellationToken, Nullable`1 millisecondsTimeout, Boolean throwExceptionIfResponseNotReceived)
 at BaristaLabs.ChromeDevTools.Runtime.ChromeSession.SendCommand[TCommand,TCommandResponse](TCommand command, CancellationToken cancellationToken, Nullable`1 millisecondsTimeout, Boolean throwExceptionIfResponseNotReceived)
 at BaristaLabs.ChromeDevTools.Runtime.Runtime.RuntimeAdapter.Evaluate(EvaluateCommand command, CancellationToken cancellationToken, Nullable`1 millisecondsTimeout, Boolean throwExceptionIfResponseNotReceived)
 --- End of inner exception stack trace ---
 at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
 at System.Threading.Tasks.Task`1.get_Result()
 at Gripper.WebClient.Browser.BaristaLabsCdtr.CdtrContext.GetBackendNodeId(Nullable`1 contextId, ChromeSession chromeSession, ILogger logger) in C:\Users\TK\source\repos\Gripper\Gripper.WebClient\Browser\BaristaLabsCdtr\CdtrContext.cs:line 37
@tomaskrupka tomaskrupka self-assigned this Dec 14, 2021
@tomaskrupka tomaskrupka reopened this Dec 14, 2021
@tomaskrupka
Copy link
Owner Author

This may happen when more than one execution contexts are related to the same iFrame. This happens when

  • All of them are valid, usually one is the DOM and the others are the background workers.
  • One of them is a zombie that remained in the lookup after it got destroyed. This means an ExecutionContextContextDestroyed event had been missed which is a bug.

@tomaskrupka tomaskrupka changed the title CdtrChromeClient.MainContext crashes on NullReferenceException. More execution contexts related to one frame Dec 15, 2021
@tomaskrupka
Copy link
Owner Author

Current implementation blindly takes the context with the greatest context id as the proper one for a given frame. This is OK in case of missed ExecutionContextDestroyed events, and most of the time for picking the DOM context as well as it's the last one to be created.

Make sure to redo this to actually identify the DOM context and pick it before merging/closing this issue.

tomaskrupka added a commit that referenced this issue Dec 16, 2021
(More execution contexts related to one frame). This takes the last context as the right one (highest id). This seems to work, but in theory it may still fail when the background worker is slower to register than the DOM. The issue remains open.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant