diff --git a/cli/tests/testdata/jupyter/integration_test.ipynb b/cli/tests/testdata/jupyter/integration_test.ipynb index 25d55e88c8fb98..b8aed651c19ce3 100644 --- a/cli/tests/testdata/jupyter/integration_test.ipynb +++ b/cli/tests/testdata/jupyter/integration_test.ipynb @@ -827,6 +827,43 @@ "let sc = new SuperColor()\n", "sc" ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "c1296291-a3e8-457b-8329-6cc58a1e528a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "class SuperColorAsync {\n", + " constructor() {\n", + " this.color = \"#239814\"\n", + " }\n", + " hex() {\n", + " return this.color\n", + " }\n", + " \n", + " async [Symbol.for(\"Jupyter.display\")]() {\n", + " return {\n", + " \"text/html\": ``\n", + " }\n", + " }\n", + "}\n", + "\n", + "let sc = new SuperColorAsync()\n", + "sc" + ] } ], "metadata": { diff --git a/cli/tools/jupyter/server.rs b/cli/tools/jupyter/server.rs index 391d202fd58e00..2c7bea9d2677c9 100644 --- a/cli/tools/jupyter/server.rs +++ b/cli/tools/jupyter/server.rs @@ -551,13 +551,13 @@ async fn get_jupyter_display( .post_message_with_event_loop( "Runtime.callFunctionOn", Some(json!({ - "functionDeclaration": r#"function (object) { + "functionDeclaration": r#"async function (object) { if (typeof object[Symbol.for("Jupyter.display")] !== "function") { return null; } - + try { - const representation = object[Symbol.for("Jupyter.display")](); + const representation = await object[Symbol.for("Jupyter.display")](); return JSON.stringify(representation); } catch { return null;