Skip to content

Commit

Permalink
fix(repl): prevent panic when deleting globalThis.closed property (de…
Browse files Browse the repository at this point in the history
  • Loading branch information
safaa-mojahed committed Jun 18, 2024
1 parent 6819c3d commit 4b83ce8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cli/tools/repl/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "_", {{
Expand Down Expand Up @@ -299,8 +302,9 @@ impl ReplSession {
}

pub async fn closing(&mut self) -> Result<bool, AnyError> {
let expression = format!(r#"{}.closed"#, *REPL_INTERNALS_NAME);
let closed = self
.evaluate_expression("(this.closed)")
.evaluate_expression(&expression)
.await?
.result
.value
Expand Down

0 comments on commit 4b83ce8

Please sign in to comment.