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 locator.click parse #1164

Merged
merged 3 commits into from
Jan 22, 2024
Merged

Refactor locator.click parse #1164

merged 3 commits into from
Jan 22, 2024

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Jan 18, 2024

What?

Refactor locator.click so that it parses the goja value using the goja runtime on the main goja thread and not in a new goroutine.

Why?

This will avoid race issues since the goja runtime is not thread safe since it is a JS interpreter that is single threaded.

I've also confirmed that this API doesn't work with goja anywhere else, including when working with eval, which is does since it uses newPointerAction, which calls waitForSelector, that calls ,evalWithScript and eventually eval, but since returnByValue is false it doesn't work with goja to transform the return value to a goja value.

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: #1162

inancgumus
inancgumus previously approved these changes Jan 19, 2024
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

LGTM 👍

browser/mapping.go Outdated Show resolved Hide resolved
ka3de
ka3de previously approved these changes Jan 19, 2024
@ankur22 ankur22 dismissed stale reviews from ka3de and inancgumus via eddc74e January 19, 2024 14:18
@ankur22 ankur22 changed the base branch from main to main-next January 19, 2024 14:20
This will be used by several of the click APIs to parse the options
using the goja runtime before the core work is done async in a
goroutine off the main event loop thread.
This avoids an issue with using the goja runtime within a promise
outside of the main event loop thread, by moving the parsing of
the option to the main event loop thread.
It's a lot clearer as to what is going on if the parse error in the
mapping layer for locator.click is returned before the promise is
initiated.
@ankur22 ankur22 merged commit b34ecf1 into main-next Jan 22, 2024
14 checks passed
@ankur22 ankur22 deleted the fix/locator-click-goja branch January 22, 2024 12:28
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.

3 participants