delete command on timeout
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kieran 2024-02-29 12:13:08 +00:00
parent ed7929db50
commit a0aa86a0b3
2 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/worker-relay", "name": "@snort/worker-relay",
"version": "1.0.2", "version": "1.0.3",
"description": "A nostr relay in a service worker", "description": "A nostr relay in a service worker",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -73,6 +73,7 @@ export class WorkerRelayInterface {
this.#worker.postMessage(msg); this.#worker.postMessage(msg);
return await new Promise<R>((resolve, reject) => { return await new Promise<R>((resolve, reject) => {
const t = setTimeout(() => { const t = setTimeout(() => {
this.#commandQueue.delete(id);
reject(new Error("Timeout")); reject(new Error("Timeout"));
}, this.timeout); }, this.timeout);
this.#commandQueue.set(id, (v, port) => { this.#commandQueue.set(id, (v, port) => {