summaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-02-24 22:56:54 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-02-24 22:56:54 +0530
commit02c265f68488c5f6b65a1b889d626f5c1dedb2a9 (patch)
tree689e97c468a81aab2576cd3ff82305aa827bdd12 /src/crypto
parent1cc8500cb036b0158d53a5a02531255ffb3b8545 (diff)
downloadwallet-core-02c265f68488c5f6b65a1b889d626f5c1dedb2a9.tar.gz
wallet-core-02c265f68488c5f6b65a1b889d626f5c1dedb2a9.tar.bz2
wallet-core-02c265f68488c5f6b65a1b889d626f5c1dedb2a9.zip
only import worker_threads when we create a worker factory
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/workers/nodeThreadWorker.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/crypto/workers/nodeThreadWorker.ts b/src/crypto/workers/nodeThreadWorker.ts
index 35aa657ba..e40f3c950 100644
--- a/src/crypto/workers/nodeThreadWorker.ts
+++ b/src/crypto/workers/nodeThreadWorker.ts
@@ -19,8 +19,6 @@ import { CryptoWorkerFactory } from "./cryptoApi";
// tslint:disable:no-var-requires
import { CryptoWorker } from "./cryptoWorker";
-
-import worker_threads = require("worker_threads");
import os = require("os");
import { CryptoImplementation } from "./cryptoImplementation";
@@ -84,6 +82,7 @@ export function handleWorkerMessage(msg: any) {
try {
const result = (impl as any)[operation](...args);
+ const worker_threads = require("worker_threads");
const p = worker_threads.parentPort;
worker_threads.parentPort?.postMessage;
if (p) {
@@ -133,9 +132,10 @@ class NodeThreadCryptoWorker implements CryptoWorker {
*/
onerror: undefined | ((m: any) => void);
- private nodeWorker: worker_threads.Worker;
+ private nodeWorker: import("worker_threads").Worker;
constructor() {
+ const worker_threads = require("worker_threads");
this.nodeWorker = new worker_threads.Worker(workerCode, { eval: true });
this.nodeWorker.on("error", (err: Error) => {
console.error("error in node worker:", err);