this.#worker = new Worker(this.#url, { type: 'module' })
this.#worker.addEventListener('message', this.#report)
this.#worker.addEventListener('error', this.terminate)
+ this.#worker.addEventListener('messageerror', this.terminate)
}
NODE: {
this.#worker = new NodeWorker(vaultWorker, {
})
this.#url = dec.toString(this.#worker.threadId)
this.#worker.on('message', listener)
+ this.#worker.on('error', this.terminate)
+ this.#worker.on('messageerror', this.terminate)
}
}
const { taskUrl, taskId, error, isLocked } = results
if (taskUrl === this.#url) {
if (typeof taskId !== 'string') {
- throw new Error('Vault worker job invalid ID', { cause: typeof taskId })
+ return this.terminate()
}
if (typeof isLocked === 'boolean' && this.#isLocked !== isLocked) {
this.#isLocked = isLocked
}
if (taskId === 'autolock') return
const task = this.#tasks.get(taskId)
- this.#tasks.delete(taskId)
if (task == null) {
- throw new Error(`Vault worker returned results without an associated task for ID ${taskId}`)
+ console.warn(`Vault worker returned results without an associated task for ID ${taskId}`)
+ return
}
- const { resolve, reject } = task
+ const { resolve, reject, timeout } = task
+ this.#tasks.delete(taskId)
+ clearTimeout(timeout)
if (error != null) {
reject(new Error(String(error)))
} else {