-
Notifications
You must be signed in to change notification settings - Fork 41
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
Move Async API Handling to Mapping Layer #683
Labels
Milestone
Comments
inancgumus
added
async
supports async (promises)
compatibility
k6 core compatibility
labels
Jan 3, 2023
inancgumus
added
the
next
Might be eligible for the next planning (not guaranteed!)
label
Jan 3, 2023
inancgumus
changed the title
Map Async APIs to Goja
Abstract Async API handling from the extension core
Jan 10, 2023
inancgumus
changed the title
Abstract Async API handling from the extension core
Separate Async/Promise handling from the extension core
Jan 10, 2023
inancgumus
added a commit
that referenced
this issue
Jan 11, 2023
Exposing VU is preliminary for using promises in the mapping layer. Updates: #683
inancgumus
added a commit
that referenced
this issue
Jan 11, 2023
Exposing VU is preliminary for using promises in the mapping layer. Updates: #683
inancgumus
added a commit
that referenced
this issue
Jan 12, 2023
Exposing VU is preliminary for using promises in the mapping layer. Updates: #683
This was referenced Jan 12, 2023
inancgumus
added
mapping
k6 browser to Goja mapping related.
refactor
dx
developer experience
labels
Jan 13, 2023
inancgumus
changed the title
Separate Async/Promise handling from the extension core
Pre-merge: k6 browser Async API to Goja mapping
Jan 18, 2023
This was referenced Jan 19, 2023
This was referenced Jan 20, 2023
Done done done 🥳 |
inancgumus
changed the title
Pre-merge: k6 browser Async API to Goja mapping
Pre-merge: Map k6-browser Async API to Goja
Jan 23, 2023
inancgumus
added a commit
that referenced
this issue
Feb 2, 2023
This is a continuation of the efforts set in #683. Handling the Async API handling in the mapping layer.
inancgumus
added a commit
that referenced
this issue
Feb 2, 2023
This is a continuation of the efforts set in #683. Handling the Async API handling in the mapping layer.
inancgumus
changed the title
Pre-merge: Map k6-browser Async API to Goja
Move Async API Handling to Mapping Layer
Feb 2, 2023
inancgumus
added a commit
that referenced
this issue
Feb 2, 2023
This is a continuation of the efforts set in #683. Handling the Async API handling in the mapping layer.
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue concerns an architectural redesign for the upcoming Async API and improving the k6 browser Async API to Goja mapping.
The problems this issue solves
POC
Here's a POC for this issue.
Sub issues
Mapping Async APIs
The current problem is that when a function returns a value in a promise, we can't map the returned value in the mapping layer.
So the missing piece of the puzzle is:
These all should happen in the mapping layer to correctly map the Async methods.
Example
page.goto(...)
returns a promise.response
object.response
object has aframe()
method.query
method that we want to map to the$
wildcard.But we can't map the returned
response.frame()
method in the mapping layer because theresponse
object is returned in a promise. We can't get theresponse
object in the mapping layer until the promise is resolved (happening on the Goja side).To understand it better, let's take a look at the following.
For example, the following code works: We use the
query
method to get the element.However, the following code does not work:
Without maping the
$
to thequery
method, the above code won't work. Notice that the above code uses$
to get the element.Currently, we couldn't map the
response.frame()
in the mapping layer. So why we can't map theresponse.frame().$
to theresponse.frame().query
? It's because theresponse.frame()
function returns a promise, and we can't get theresponse
object in the mapping layer until the promise is resolved.Solution
Instead of
page.goto
returning a promise, we can directly make it return aresponse
object. And then, we can map theresponse.frame()
method in the mapping layer.That means we must move the promise returning/handling functionality to the mapping layer. This will be critical when we fully switch to the Async API. Since we also need it now, we can start moving the promise returning/handling functionality to the mapping layer.
Doing so will also help us separate the Goja logic from our core logic. The code and tests will be easier to maintain and work with. And we'll be ready for the incoming Async/Promise support (#428). I'll send a POC soon.
Related: #661
The text was updated successfully, but these errors were encountered: