diff options
author | Kyle Kelley <rgbkrk@gmail.com> | 2023-10-04 14:08:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-04 23:08:57 +0200 |
commit | cbddf5756e07fbbe10bd35d23bb9e9c0c685442a (patch) | |
tree | b3482b28c79d3caa83384279a1e4f2f157970056 /cli/tools/jupyter/server.rs | |
parent | a5568066b3d979111134029f9e4f0c1b462b948e (diff) |
fix(jupyter): keep `this` around (#20789)
This fixes #20767.
We were losing `this` and then when an exception was happening, it
didn't show up in the output because we weren't bubbling up exceptions
from within a user defined function for displaying. I thought about
doing a `.call(object)` but didn't want to get in the way of a bound
`this` that a user or library was already putting on the function.
Diffstat (limited to 'cli/tools/jupyter/server.rs')
-rw-r--r-- | cli/tools/jupyter/server.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/cli/tools/jupyter/server.rs b/cli/tools/jupyter/server.rs index 2489fcd04..0b8d25c3e 100644 --- a/cli/tools/jupyter/server.rs +++ b/cli/tools/jupyter/server.rs @@ -554,14 +554,13 @@ async fn get_jupyter_display( "Runtime.callFunctionOn", Some(json!({ "functionDeclaration": r#"function (object) { - const display = object[Symbol.for("Jupyter.display")]; - - if (typeof display !== "function") { + if (typeof object[Symbol.for("Jupyter.display")] !== "function") { return null; } try { - return JSON.stringify(display()); + const representation = object[Symbol.for("Jupyter.display")](); + return JSON.stringify(representation); } catch { return null; } |