diff --git a/package-lock.json b/package-lock.json index a21c529..d0c9b1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "paravel", - "version": "0.1.10", + "version": "0.1.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "paravel", - "version": "0.1.10", + "version": "0.1.11", "license": "MIT", "dependencies": { "husky": "^8.0.3", diff --git a/package.json b/package.json index 705b6c0..a80a057 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "paravel", - "version": "0.1.10", + "version": "0.1.11", "description": "Yet another toolkit for nostr", "repository": { "type": "git", diff --git a/src/util/Socket.ts b/src/util/Socket.ts index 2535a1d..113ef55 100644 --- a/src/util/Socket.ts +++ b/src/util/Socket.ts @@ -10,6 +10,7 @@ export class Socket { queue: string[] bus: EventBus status: string + error?: Error _onOpen: (e: any) => void _onMessage: (e: any) => void _onError: (e: any) => void @@ -21,15 +22,14 @@ export class Socket { READY: "ready", } constructor(url: string) { - this.ws = undefined this.url = url this.ready = defer() - this.timeout = undefined this.queue = [] this.bus = new EventBus() this.status = Socket.STATUS.NEW this._onOpen = () => { + this.error = undefined this.status = Socket.STATUS.READY this.ready.resolve() this.bus.emit('open') @@ -43,8 +43,9 @@ export class Socket { } } - this._onError = (err: Error) => { - this.bus.emit('error', err) + this._onError = (error: Error) => { + this.error = error + this.bus.emit('error', error) } this._onClose = () => {