diff --git a/src/index.js b/src/index.js index 17ca431..d94e80e 100644 --- a/src/index.js +++ b/src/index.js @@ -175,7 +175,11 @@ function validateXML(options) { addEventListener('message', onmessage); addEventListener('error', onerror); worker.postMessage(preprocessedOptions); - }).finally(() => worker.terminate()); + }).finally(() => { + if (worker) { + return worker.terminate(); + } + }); } // #ifdef browser