From 4db4cd96794a65bada83798131db4ff366c09282 Mon Sep 17 00:00:00 2001 From: William Wong Date: Wed, 5 Apr 2023 21:11:36 +0000 Subject: [PATCH 1/2] Catch all async calls --- CHANGELOG.md | 4 ++++ src/directLineStreaming.ts | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daecf183..64e809c7 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 [#XXX](https://github.com/microsoft/BotFramework-DirectLineJS/pull/XXX) + ## [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() { From a084cb7cdce9320e3b4a1f3c7b6e4aa89d3ca43d Mon Sep 17 00:00:00 2001 From: William Wong Date: Wed, 5 Apr 2023 21:13:57 +0000 Subject: [PATCH 2/2] Update PR number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64e809c7..5531bbce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### 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 [#XXX](https://github.com/microsoft/BotFramework-DirectLineJS/pull/XXX) +- 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