From 5cefbba75777547f97abd92affcf9ef10ac36163 Mon Sep 17 00:00:00 2001 From: Radamés Ajna Date: Thu, 14 Sep 2023 22:30:50 -0700 Subject: minor UI fixes (#856) * fixes * remove listener * remove event listener --- candle-wasm-examples/llama2-c/lib-example.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'candle-wasm-examples/llama2-c') diff --git a/candle-wasm-examples/llama2-c/lib-example.html b/candle-wasm-examples/llama2-c/lib-example.html index 22b12517..86fe9811 100644 --- a/candle-wasm-examples/llama2-c/lib-example.html +++ b/candle-wasm-examples/llama2-c/lib-example.html @@ -6,7 +6,7 @@ - + @@ -113,8 +113,14 @@ const handleMessage = (event) => { const { status, error, message, prompt, sentence } = event.data; if (status) updateStatus(event.data); - if (error) reject(new Error(error)); - if (status === "complete") resolve(event.data); + if (error) { + llamaWorker.removeEventListener("message", handleMessage); + reject(new Error(error)); + } + if (status === "complete") { + llamaWorker.removeEventListener("message", handleMessage); + resolve(event.data); + } }; controller.signal.addEventListener("abort", handleAbort); -- cgit v1.2.3