From c4d088863e93b70fa0729f326ad14376ca90b0a6 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 10 Sep 2024 08:14:26 +0530 Subject: [PATCH] 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 --- ext/node/ops/require.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs index def1d97587..4f88c1913b 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::>>(); - inspector - .borrow_mut() - .wait_for_session_and_break_on_next_statement() +#[op2(fast, reentrant)] +pub fn op_require_break_on_next_statement(state: Rc>) { + let inspector_rc = { + let state = state.borrow(); + state.borrow::>>().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 {