From 3ca152a966b776a07a8b81ff1408fe0d4ffd2376 Mon Sep 17 00:00:00 2001
From: Matt Strapp <matt@mattstrapp.net>
Date: Fri, 29 Sep 2023 09:46:26 -0500
Subject: Destroy web worker when navigated away

Signed-off-by: Matt Strapp <matt@mattstrapp.net>
---
 app/src/routes/truncate/+page.svelte | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'app/src/routes/truncate/+page.svelte')

diff --git a/app/src/routes/truncate/+page.svelte b/app/src/routes/truncate/+page.svelte
index 104785d..e0dda30 100644
--- a/app/src/routes/truncate/+page.svelte
+++ b/app/src/routes/truncate/+page.svelte
@@ -4,7 +4,7 @@
   import Icon from '@iconify/svelte';
   import fileStorage from '@iconify/icons-carbon/file-storage';
   import { FileDropzone, ProgressBar } from '@skeletonlabs/skeleton';
-  import { onMount } from 'svelte';
+  import { onDestroy, onMount } from 'svelte';
 
   let disableInput = false;
   let files: FileList;
@@ -31,6 +31,10 @@
       truncateTo = 1;
     };
   });
+
+  onDestroy(() => {
+    worker.terminate()
+  })
 </script>
 
 <svelte:head>
-- 
cgit v1.2.3

