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

Refactor elementHandle.click parse #1171

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Jan 19, 2024

What?

Move the parse logic for elementHandle.click into the mapping layer to reduce the call to the goja runtime by one less call.

Why?

This will mitigate the risk of a panic occurring due to using the goja runtime in a new goroutine off the main goja thread. This doesn't solve the complete problem and it still relie on using the goja runtime, but that issue can be tracked separately (#1170).

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Updates: #1169

@ankur22 ankur22 changed the base branch from main-next to fix/locator-click-goja January 19, 2024 15:39
@ankur22 ankur22 changed the base branch from fix/locator-click-goja to main January 19, 2024 15:39
@ankur22 ankur22 changed the base branch from main to main-next January 19, 2024 15:40
@ankur22 ankur22 force-pushed the refactor/elementHandle-click-parse branch from 3228f1d to e1e13bf Compare January 19, 2024 15:40
@ankur22 ankur22 changed the base branch from main-next to fix/locator-click-goja January 19, 2024 15:40
@ankur22 ankur22 force-pushed the refactor/elementHandle-click-parse branch 2 times, most recently from 44eeb8d to 44440af Compare January 19, 2024 15:41
"click": func(opts goja.Value) (*goja.Promise, error) {
ctx := vu.Context()

popts := common.NewElementHandleClickOptions(eh.Timeout())
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: What does popts stand for? Should it be clickOpts?

Copy link
Member

Choose a reason for hiding this comment

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

I think copts would be fine for "click options".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

popts -> parsed options. Aren't opts before being parsed also click options? I prefer popts.

Copy link
Member

Choose a reason for hiding this comment

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

popts and copts are both fine to me.

Base automatically changed from fix/locator-click-goja to main-next January 22, 2024 12:28
This will be used in the mapping layer to retrieve the default timeout
that needs to be used when parsing options.
Move the parsing of the options for elementHandle.click outside of the
promise goroutine and back onto the main goja thread in the mapping
layer. This will help mitigate the risk of a panic if more than one
goroutine is accessing the goja runtime off the main goja thread.

This doesn't solve the problem completely though since this API calls
to other areas of the codebase which does still interact with the goja
runtime. See #1170 for
further details.
@ankur22 ankur22 force-pushed the refactor/elementHandle-click-parse branch from 44440af to f8f0f35 Compare January 23, 2024 13:37
@ankur22 ankur22 merged commit 7e4b794 into main-next Jan 23, 2024
14 checks passed
@ankur22 ankur22 deleted the refactor/elementHandle-click-parse branch January 23, 2024 13:54
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

Successfully merging this pull request may close these issues.

None yet

3 participants