Skip to content

Commit f363edc

Browse files
Preslav LeConvex, Inc.
authored andcommitted
Remove with_request_scope from isolate (#24554)
I was pleasantly surprised that this is not used anymore so one less thing to refactor. GitOrigin-RevId: 8b004f08d0c0c7290ed7d0534c8b19d107b79c49
1 parent 186eeed commit f363edc

File tree

1 file changed

+1
-43
lines changed

1 file changed

+1
-43
lines changed

crates/isolate/src/isolate.rs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ use crate::{
2929
create_isolate_timer,
3030
log_heap_statistics,
3131
},
32-
request_scope::{
33-
RequestScope,
34-
RequestState,
35-
},
32+
request_scope::RequestState,
3633
strings,
3734
termination::{
3835
IsolateHandle,
@@ -265,45 +262,6 @@ impl<RT: Runtime> Isolate<RT> {
265262
Ok(())
266263
}
267264

268-
pub async fn with_request_scope<E: IsolateEnvironment<RT>, R>(
269-
&mut self,
270-
environment: E,
271-
allow_dynamic_imports: bool,
272-
f: impl FnOnce(&mut RequestScope<RT, E>) -> anyhow::Result<R>,
273-
) -> anyhow::Result<R> {
274-
// Set up our timeout and environment for the new context.
275-
let (handle, state) = self.start_request(environment).await?;
276-
277-
// Create a new `v8::HandleScope` on the stack.
278-
let mut handle_scope = self.handle_scope();
279-
280-
// Create a new `v8::Context` that points to the handle scope.
281-
let v8_context = v8::Context::new(&mut handle_scope);
282-
283-
// Connect the context to the handle scope with a new `v8::ContextScope`.
284-
let mut context_scope = v8::ContextScope::new(&mut handle_scope, v8_context);
285-
286-
// Create our `IsolateContext` with a pointer to the stack-allocated context
287-
// scope.
288-
let mut isolate_context =
289-
RequestScope::new(&mut context_scope, handle, state, allow_dynamic_imports).await?;
290-
291-
// Run the user's code.
292-
let result = f(&mut isolate_context);
293-
294-
// Drain the microtask queue, to clean up the isolate.
295-
isolate_context.scope.perform_microtask_checkpoint();
296-
297-
// Unlink the request from the isolate.
298-
// After this point, it's unsafe to run js code in the isolate that
299-
// expects the current request's environment.
300-
// If the microtask queue is somehow nonempty after this point but before
301-
// the next request starts, the isolate may panic.
302-
drop(isolate_context);
303-
304-
result
305-
}
306-
307265
pub async fn start_request<E: IsolateEnvironment<RT>>(
308266
&mut self,
309267
environment: E,

0 commit comments

Comments
 (0)