diff --git a/CHANGELOG.md b/CHANGELOG.md index daecf183..5531bbce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Fixed [#398](https://github.com/microsoft/BotFramework-DirectLineJS/issues/398). In `DirectLineStreaming`, all calls to async function should be caught and rethrow appropriately, by [@compulim](https://github.com/compulim) in PR [#399](https://github.com/microsoft/BotFramework-DirectLineJS/pull/399) + ## [0.15.2] - 2023-03-21 ### Changed diff --git a/src/directLineStreaming.ts b/src/directLineStreaming.ts index 4c060c31..cd5b2b78 100644 --- a/src/directLineStreaming.ts +++ b/src/directLineStreaming.ts @@ -109,7 +109,9 @@ export class DirectLineStreaming implements IBotConnection { constructor(options: DirectLineStreamingOptions) { this.token = options.token; - this.refreshToken(); + this.refreshToken().catch(() => { + this.connectionStatus$.next(ConnectionStatus.ExpiredToken); + }); this.domain = options.domain; @@ -123,14 +125,20 @@ export class DirectLineStreaming implements IBotConnection { this.activity$ = Observable.create(async (subscriber: Subscriber) => { this.activitySubscriber = subscriber; this.theStreamHandler = new StreamHandler(subscriber, this.connectionStatus$, () => this.queueActivities); - this.connectWithRetryAsync(); + + try { + await this.connectWithRetryAsync(); + } catch (error) { + this.connectionStatus$.next(ConnectionStatus.FailedToConnect); + } }).share(); } - public reconnect({ conversationId, token } : Conversation) { + public async reconnect({ conversationId, token } : Conversation) { this.conversationId = conversationId; this.token = token; - this.connectAsync(); + + await this.connectAsync(); } end() {