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

Allow awaiting JsPromise from Rust code #3011

Merged
merged 3 commits into from Jun 18, 2023
Merged

Allow awaiting JsPromise from Rust code #3011

merged 3 commits into from Jun 18, 2023

Conversation

jedel1043
Copy link
Member

@jedel1043 jedel1043 commented Jun 8, 2023

Should be mostly useful for consumers of the JobQueue::enqueue_future_job API, since they can now await for certain promises inside async blocks and functions.

Changes:

  • Adds a new JsFuture type that implements Future.
  • Adds a new JsPromise::into_js_future method.
  • Rewrites the caveats section of NativeFunction::from_async_fn, since the old explanation was wrong.
  • Adds a new JsPromise::from_future constructor.
  • Improves some promise code.

@jedel1043 jedel1043 added enhancement New feature or request API labels Jun 8, 2023
@jedel1043 jedel1043 added this to the v0.17.0 milestone Jun 8, 2023
@jedel1043 jedel1043 requested a review from a team June 8, 2023 04:08
@github-actions
Copy link

github-actions bot commented Jun 8, 2023

Test262 conformance changes

Test result main count PR count difference
Total 94,108 94,108 0
Passed 74,670 74,670 0
Ignored 17,740 17,740 0
Failed 1,698 1,698 0
Panics 0 0 0
Conformance 79.35% 79.35% 0.00%

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #3011 (80e9b89) into main (45e0b88) will decrease coverage by 0.06%.
The diff coverage is 8.21%.

@@            Coverage Diff             @@
##             main    #3011      +/-   ##
==========================================
- Coverage   50.56%   50.50%   -0.06%     
==========================================
  Files         446      446              
  Lines       45902    46008     +106     
==========================================
+ Hits        23210    23236      +26     
- Misses      22692    22772      +80     
Impacted Files Coverage Δ
boa_engine/src/native_function.rs 67.64% <0.00%> (+16.53%) ⬆️
boa_engine/src/object/builtins/jspromise.rs 0.00% <0.00%> (ø)
boa_gc/src/trace.rs 83.33% <ø> (ø)
boa_icu_provider/src/lib.rs 100.00% <ø> (ø)
boa_engine/src/builtins/promise/mod.rs 31.62% <50.00%> (-0.66%) ⬇️

... and 30 files with indirect coverage changes

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Nice addition!

@jedel1043 jedel1043 requested a review from a team June 9, 2023 19:54
Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Looking great! I added a couple of suggestions for two doc links. We might want to mention this in boa-dev/boa-dev.github.io#94

boa_engine/src/object/builtins/jspromise.rs Outdated Show resolved Hide resolved
boa_engine/src/object/builtins/jspromise.rs Outdated Show resolved Hide resolved
@jedel1043 jedel1043 enabled auto-merge June 17, 2023 23:35
@jedel1043 jedel1043 added this pull request to the merge queue Jun 17, 2023
Merged via the queue into main with commit 1a21cc9 Jun 18, 2023
9 checks passed
@jedel1043 jedel1043 deleted the promise-utils branch June 18, 2023 00:19
Razican pushed a commit that referenced this pull request Jun 26, 2023
* Allow awaiting `JsPromise` from Rust code

* Fix docs

* Relink to docs.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants