-
Notifications
You must be signed in to change notification settings - Fork 42
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
Conversation
There was a problem hiding this 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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/popts/clickOpts
There was a problem hiding this comment.
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.
8b21fdf
to
0aabdc8
Compare
7875f68
to
3b92c86
Compare
0aabdc8
to
76cbf90
Compare
This timeout method is to be called from the mapping layer when parsing options.
47c1d65
to
9cbdd2f
Compare
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
9cbdd2f
to
d57dba3
Compare
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
Related PR(s)/Issue(s)
Updates: #1174