Repository navigation
Use safe rooted handles in stream callbacks - #48226
Merged
Merged
Conversation
Signed-off-by: Taym Haddadi <[email protected]>
Taym95
force-pushed
the
safe-rooted-stream-callbacks
branch
from
September 20, 2026 15:46
dc542cd to
26a4ebe
Compare
sagudev
reviewed
Sep 20, 2026
Comment on lines
+216
to
+218
| /// Check whether a value is a promise. | ||
| #[expect(unsafe_code)] | ||
| pub(crate) fn is_promise_value(value: HandleValue, mut object: MutableHandleObject) -> bool { |
Member
There was a problem hiding this comment.
I think we should be more descriptive here, as we do not just do the check here. Actually given that every user does something like:
let promise = if is_promise {
Promise::new_with_js_promise(cx, result_object.handle())
} else {
Promise::new_resolved(cx, global, result.get())
};maybe we should be also include this here so we will always return promise:
/// returns rust promise if value is promise object
/// otherwise creates new resolved rust promise with value
fn resolve_or_wrap_promise(cx: &mut JSContext, value: HandleValue, global) -> Promise {
rooted!(&in(cx) let mut result_object = ptr::null_mut::<JSObject>());
let is_promise = unsafe {
if value.is_object() {
result_object.set(value.to_object());
IsPromiseObject(result_object.handle().into_handle())
} else {
false
}
};
let promise = if is_promise {
Promise::new_with_js_promise(cx, result_object.handle())
} else {
Promise::new_resolved(cx, global, value.get())
};
}Signed-off-by: Taym Haddadi <[email protected]>
sagudev
approved these changes
Sep 20, 2026
| } | ||
| if let Err(error) = start.Call_( | ||
| cx, | ||
| &rooted_heap_handle(self, |_| this_obj), |
Member
There was a problem hiding this comment.
NOTE-TO-SELF: while we do project rootedness here, we go from self->underlying_source_type->this_obj
RichardTjokroutomo
pushed a commit
to RichardTjokroutomo/servo
that referenced
this pull request
Oct 6, 2026
replace `SafeHandle::from_raw` calls with `rooted_heap_handle` in UnderlyingSource callbacks and add `Promise::is_promise_value` to centralize the object check. Testing: No behavior change, existing WPT tests passed locally. Fixes: Part of [servo#30862](servo#30862) --------- Signed-off-by: Taym Haddadi <[email protected]>
hhhwsqhhh
pushed a commit
to hhhwsqhhh/servo
that referenced
this pull request
Oct 12, 2026
replace `SafeHandle::from_raw` calls with `rooted_heap_handle` in UnderlyingSource callbacks and add `Promise::is_promise_value` to centralize the object check. Testing: No behavior change, existing WPT tests passed locally. Fixes: Part of [servo#30862](servo#30862) --------- Signed-off-by: Taym Haddadi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
replace
SafeHandle::from_rawcalls withrooted_heap_handlein UnderlyingSource callbacks and addPromise::is_promise_valueto centralize the object check.Testing: No behavior change, existing WPT tests passed locally.
Fixes: Part of #30862