From ff44d58c5fd87d8d20454adc5de24135334c453b Mon Sep 17 00:00:00 2001 From: Cong Zhang <13283869+congzhangzh@users.noreply.github.com> Date: Sat, 2 Nov 2024 18:09:21 +0800 Subject: [PATCH] fix: fix preload logic --- src/ffi.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ffi.ts b/src/ffi.ts index bcf93ed..fff7bae 100644 --- a/src/ffi.ts +++ b/src/ffi.ts @@ -88,12 +88,14 @@ export function unload() { // Automatically run the preload if we're on windows and on the main thread. if (Deno.build.os === "windows") { - if (self === globalThis) { - await preload(); - } else if (!await checkForWebView2Loader()) { - throw new Error( - "WebView2Loader.dll does not exist! Make sure to run preload() from the main thread.", - ); + if (!await checkForWebView2Loader()) { + if (self === globalThis) { + await preload(); + } else { + throw new Error( + "WebView2Loader.dll does not exist! Make sure to run preload() from the main thread.", + ); + } } }