diff --git a/sdk/src/events/eventSubscriber.ts b/sdk/src/events/eventSubscriber.ts index 5cdffe364..02dad82d7 100644 --- a/sdk/src/events/eventSubscriber.ts +++ b/sdk/src/events/eventSubscriber.ts @@ -171,10 +171,20 @@ export class EventSubscriber { this.logProvider.eventEmitter.on( 'reconnect', async (reconnectAttempts) => { - if (reconnectAttempts > logProviderConfig.maxReconnectAttempts) { - console.log( - `EventSubscriber: Reconnect attempts ${reconnectAttempts}/${logProviderConfig.maxReconnectAttempts}, reconnecting...` - ); + const hitMaxReconnectAttempts = + reconnectAttempts > logProviderConfig.maxReconnectAttempts; + + console.log( + `EventSubscriber: Reconnect attempts ${reconnectAttempts}/${ + logProviderConfig.maxReconnectAttempts + }, ${ + hitMaxReconnectAttempts + ? 'Falling Back...' + : 'Reconnecting...' + }` + ); + + if (hitMaxReconnectAttempts) { this.logProvider.eventEmitter.removeAllListeners('reconnect'); await this.unsubscribe(); this.updateFallbackProviderType( diff --git a/sdk/src/events/eventsServerLogProvider.ts b/sdk/src/events/eventsServerLogProvider.ts index 798890a68..8aacd4fcc 100644 --- a/sdk/src/events/eventsServerLogProvider.ts +++ b/sdk/src/events/eventsServerLogProvider.ts @@ -77,7 +77,17 @@ export class EventsServerLogProvider implements LogProvider { if (parsedData.message !== undefined) { return; } - const event = JSON.parse(parsedData.data); + let event = JSON.parse(parsedData.data); + + try { + // Handling for double-serialised events + if (typeof event === 'string') { + event = JSON.parse(event); + } + } catch (error) { + // swallow + } + this.callback( event.txSig, event.slot,