summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-09-10 08:14:26 +0530
committerGitHub <noreply@github.com>2024-09-10 08:14:26 +0530
commitc4d088863e93b70fa0729f326ad14376ca90b0a6 (patch)
tree2f6d746a008346d46fa8c2b991c4ad3b17b6751a
parent4af98fa82f87dedfa6cc4a48231329fbc948836b (diff)
fix(inspector): Fix panic when re-entering runtime ops (#25537)
Mark `op_require_break_on_next_statement` as reentrant and properly release borrow on the `OpState`. This fixes `BorrowMut` assertions when running with inspector + op metrics. Fixes https://github.com/denoland/deno/issues/25515
-rw-r--r--ext/node/ops/require.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs
index def1d9758..4f88c1913 100644
--- a/ext/node/ops/require.rs
+++ b/ext/node/ops/require.rs
@@ -591,12 +591,14 @@ where
}
}
-#[op2(fast)]
-pub fn op_require_break_on_next_statement(state: &mut OpState) {
- let inspector = state.borrow::<Rc<RefCell<JsRuntimeInspector>>>();
- inspector
- .borrow_mut()
- .wait_for_session_and_break_on_next_statement()
+#[op2(fast, reentrant)]
+pub fn op_require_break_on_next_statement(state: Rc<RefCell<OpState>>) {
+ let inspector_rc = {
+ let state = state.borrow();
+ state.borrow::<Rc<RefCell<JsRuntimeInspector>>>().clone()
+ };
+ let mut inspector = inspector_rc.borrow_mut();
+ inspector.wait_for_session_and_break_on_next_statement()
}
fn url_to_file_path_string(url: &Url) -> Result<String, AnyError> {