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

Make the HostHooks shareable between app and context #4141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Jan 22, 2025

Previously it was very difficult to keep a stateful HostHooks, since it needed to be a static reference. Now it can be shared. This is particularly useful for mocking hooks for testing.

This also follows the pattern for the job executor and the module loader.

I did not see any impact on performance.

@hansl hansl requested a review from a team January 22, 2025 19:48
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 90.47619% with 4 lines in your changes missing coverage. Please review.

Project coverage is 53.55%. Comparing base (6ddc2b4) to head (4ec5884).
Report is 355 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/context/mod.rs 66.66% 2 Missing ⚠️
core/engine/src/builtins/date/mod.rs 97.14% 1 Missing ⚠️
core/engine/src/object/builtins/jsdate.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4141      +/-   ##
==========================================
+ Coverage   47.24%   53.55%   +6.31%     
==========================================
  Files         476      487      +11     
  Lines       46892    48874    +1982     
==========================================
+ Hits        22154    26176    +4022     
+ Misses      24738    22698    -2040     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jedel1043
Copy link
Member

IIRC we had Rc<HostHooks> before, but it was determined to be unnecessary since the hooks are not supposed to carry additional data, opting for HostDefined if some special data was needed.

I think it's fine to make it possible to add special data to the hooks, but I'm slightly worried that some subtle bugs could be triggered because the hooks are used at realm creation time.

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Preemptively approving since this is immediately useful, but it would be good to make a survey on how the host hooks are defined on other engines to be sure that we're not introducing bugs by doing this.

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.

2 participants