From 66acd979bfc1822293f2d70ac228aa02101b67c2 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 24 Jan 2020 17:07:30 +0100 Subject: [PATCH] Clear worker key caches in openpgp.destroyWorker() --- src/openpgp.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/openpgp.js b/src/openpgp.js index 6d6b06d4..495ea9e8 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -89,10 +89,12 @@ export function getWorker() { /** * Cleanup the current instance of the web worker. */ -export function destroyWorker() { - if (asyncProxy) { - asyncProxy.terminate(); - asyncProxy = undefined; +export async function destroyWorker() { + const proxy = asyncProxy; + asyncProxy = undefined; + if (proxy) { + await proxy.clearKeyCache(); + proxy.terminate(); } }