From 290cfb8189a68b4b0f5798d7b96c6dc564921713 Mon Sep 17 00:00:00 2001 From: safaa-mojahed <42294003+safaa-mojahed@users.noreply.github.com> Date: Tue, 18 Jun 2024 04:34:25 +0300 Subject: [PATCH] fix(repl): prevent panic when deleting globalThis.closed property (#24014) --- cli/tools/repl/session.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs index b122713c03..f8c670a7f1 100644 --- a/cli/tools/repl/session.rs +++ b/cli/tools/repl/session.rs @@ -99,6 +99,9 @@ Object.defineProperty(globalThis, "{0}", {{ lastThrownError: undefined, inspectArgs: Deno[Deno.internal].inspectArgs, noColor: Deno.noColor, + get closed() {{ + return typeof globalThis.closed === 'undefined' ? false : globalThis.closed; + }} }}, }}); Object.defineProperty(globalThis, "_", {{ @@ -299,8 +302,9 @@ impl ReplSession { } pub async fn closing(&mut self) -> Result { + let expression = format!(r#"{}.closed"#, *REPL_INTERNALS_NAME); let closed = self - .evaluate_expression("(this.closed)") + .evaluate_expression(&expression) .await? .result .value