diff --git a/package.json b/package.json index 7ad79f2..76bdfc1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bnc-sdk", - "version": "3.4.0", + "version": "3.4.0-0.0.1", "description": "SDK to connect to the blocknative backend via a websocket connection", "keywords": [ "ethereum", diff --git a/src/configuration.ts b/src/configuration.ts index 20e369a..6bc9f1c 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -43,10 +43,19 @@ function configuration( return new Promise((resolve, reject) => { subscription.pipe(take(1), timeout(5000)).subscribe({ next: () => resolve({ ...emitter, details: { config } }), - error: () => - reject( - `Configuration with scope: ${config.scope} has been sent to the Blocknative server, but has not received a reply within 5 seconds.` - ) + error: (error: { message: string }) => { + const message = + error.message === 'Timeout has occurred' + ? `Configuration with scope: ${config.scope} has been sent to the Blocknative server, but has not received a reply within 5 seconds.` + : error.message + + if (this._onerror) { + this._onerror({ message }) + resolve(`Error: ${message}`) + } else { + reject(message) + } + } }) }) } diff --git a/src/messages.ts b/src/messages.ts index dd8109d..e0d3528 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -170,7 +170,7 @@ export function handleMessage(this: any, msg: { data: string }): void { const configuration = this._configurations.get(event.config.scope) if (configuration && configuration.subscription) { - configuration.subscription.error(reason) + configuration.subscription.error({ message: reason }) } return