Terminate workers in openpgp.destroyWorker()
This commit is contained in:
parent
94a04eaa5c
commit
6ae6012786
|
@ -90,8 +90,11 @@ export function getWorker() {
|
||||||
* Cleanup the current instance of the web worker.
|
* Cleanup the current instance of the web worker.
|
||||||
*/
|
*/
|
||||||
export function destroyWorker() {
|
export function destroyWorker() {
|
||||||
|
if (asyncProxy) {
|
||||||
|
asyncProxy.terminate();
|
||||||
asyncProxy = undefined;
|
asyncProxy = undefined;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
|
@ -446,7 +446,8 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
|
|
||||||
it('should work', async function() {
|
it('should work', async function() {
|
||||||
const workerStub = {
|
const workerStub = {
|
||||||
postMessage: function() {}
|
postMessage: function() {},
|
||||||
|
terminate: function() {}
|
||||||
};
|
};
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
openpgp.initWorker({
|
openpgp.initWorker({
|
||||||
|
@ -600,7 +601,8 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
|
|
||||||
it('should delegate to async proxy', async function() {
|
it('should delegate to async proxy', async function() {
|
||||||
const workerStub = {
|
const workerStub = {
|
||||||
postMessage: function() {}
|
postMessage: function() {},
|
||||||
|
terminate: function() {}
|
||||||
};
|
};
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
openpgp.initWorker({
|
openpgp.initWorker({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user