script: make Error::to_jsval safe (#35411)

Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
This commit is contained in:
Stephen Muss 2025-02-11 10:47:31 +11:00 committed by GitHub
parent 8486e585f5
commit cb588bab6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 41 additions and 64 deletions

View file

@ -101,13 +101,11 @@ pub(crate) trait ReadableStreamGenericReader {
// Otherwise, set reader.[[closedPromise]] to a promise rejected with a TypeError exception.
let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut error = UndefinedValue());
unsafe {
Error::Type("Cannot release lock due to stream state.".to_owned()).to_jsval(
*cx,
&stream.global(),
error.handle_mut(),
)
};
Error::Type("Cannot release lock due to stream state.".to_owned()).to_jsval(
cx,
&stream.global(),
error.handle_mut(),
);
self.set_closed_promise(
Promise::new_rejected(&stream.global(), cx, error.handle()).unwrap(),