mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Added timeout argument to WorkerInterface.
This commit is contained in:
parent
6bcb259919
commit
3690f4acda
2 changed files with 5 additions and 3 deletions
|
@ -15,8 +15,9 @@ class TimedOutError extends Error {
|
|||
}
|
||||
|
||||
class WorkerInterface {
|
||||
constructor(path) {
|
||||
constructor(path, timeout = WORKER_TIMEOUT) {
|
||||
this._utilWorker = new Worker(path);
|
||||
this.timeout = timeout;
|
||||
this._jobs = Object.create(null);
|
||||
this._DEBUG = false;
|
||||
this._jobCounter = 0;
|
||||
|
@ -112,7 +113,7 @@ class WorkerInterface {
|
|||
|
||||
setTimeout(
|
||||
() => reject(new TimedOutError(`Worker job ${jobId} (${fnName}) timed out`)),
|
||||
WORKER_TIMEOUT
|
||||
this.timeout
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -269,8 +269,9 @@ window.LokiAPI = new LokiServer({
|
|||
window.mnemonic = require('./libloki/mnemonic');
|
||||
const { WorkerInterface } = require('./js/modules/util_worker_interface');
|
||||
|
||||
// A Worker with a 3 minute timeout
|
||||
const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js');
|
||||
const utilWorker = new WorkerInterface(utilWorkerPath);
|
||||
const utilWorker = new WorkerInterface(utilWorkerPath, 3 * 60 * 1000);
|
||||
window.callWorker = (fnName, ...args) => utilWorker.callWorker(fnName, ...args);
|
||||
|
||||
// Linux seems to periodically let the event loop stop, so this is a global workaround
|
||||
|
|
Loading…
Reference in a new issue