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 page.click option parsing #1175

Merged
merged 2 commits into from Jan 23, 2024
Merged

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Jan 19, 2024

What?

This refactors the option parsing out of the promise and into the mapping layer for page.click.

Why?

This will help mitigate the risk of a panic occurring due to multiple goroutines accessing the goja runtime (which is not thread safe) concurrently.

More works needs to be done to totally remove the goja runtime usage from within the page.click promise which can be tracked in #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: #1174

Copy link
Collaborator

@ka3de ka3de left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just left a nit comment. Also, there is a linting error for tests/webvital_test.go not being "gci-ed"

@@ -468,11 +468,16 @@ func mapPage(vu moduleVU, p *common.Page) mapping {
"addStyleTag": p.AddStyleTag,
"bringToFront": p.BringToFront,
"check": p.Check,
"click": func(selector string, opts goja.Value) *goja.Promise {
"click": func(selector string, opts goja.Value) (*goja.Promise, error) {
popts, err := parseFrameClickOptions(vu.Context(), opts, p.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: s/popts/clickOpts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll do a mass renaming later if we need. Sticking with popts for now.

Base automatically changed from refactor/frame-click-parse to main-next January 23, 2024 14:04
This timeout method is to be called from the mapping layer when parsing
options.
This helps avoid using the goja runtime when it comes to parsing the
options. The options parsing has been moved to the mapping layer and so
has been moved back on to the main goja thread, which will mitigate the
possibility of a panic which could occur when multiple goroutines try
to work with the goja runtime (which is not thread safe).

There is another issue to tackle more of the goja refactoring in
@ankur22 ankur22 merged commit 6a79f8f into main-next Jan 23, 2024
14 checks passed
@ankur22 ankur22 deleted the refactor/page-click-parse branch January 23, 2024 14:16
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