Skip to content

Commit fb239fe

Browse files
authored
[DLASE] Catch all async calls (#399)
* Catch all async calls * Update PR number
1 parent dbb4063 commit fb239fe

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616

1717
## [Unreleased]
1818

19+
### Fixed
20+
21+
- 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)
22+
1923
## [0.15.2] - 2023-03-21
2024

2125
### Changed

src/directLineStreaming.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ export class DirectLineStreaming implements IBotConnection {
109109
constructor(options: DirectLineStreamingOptions) {
110110
this.token = options.token;
111111

112-
this.refreshToken();
112+
this.refreshToken().catch(() => {
113+
this.connectionStatus$.next(ConnectionStatus.ExpiredToken);
114+
});
113115

114116
this.domain = options.domain;
115117

@@ -123,14 +125,20 @@ export class DirectLineStreaming implements IBotConnection {
123125
this.activity$ = Observable.create(async (subscriber: Subscriber<Activity>) => {
124126
this.activitySubscriber = subscriber;
125127
this.theStreamHandler = new StreamHandler(subscriber, this.connectionStatus$, () => this.queueActivities);
126-
this.connectWithRetryAsync();
128+
129+
try {
130+
await this.connectWithRetryAsync();
131+
} catch (error) {
132+
this.connectionStatus$.next(ConnectionStatus.FailedToConnect);
133+
}
127134
}).share();
128135
}
129136

130-
public reconnect({ conversationId, token } : Conversation) {
137+
public async reconnect({ conversationId, token } : Conversation) {
131138
this.conversationId = conversationId;
132139
this.token = token;
133-
this.connectAsync();
140+
141+
await this.connectAsync();
134142
}
135143

136144
end() {

0 commit comments

Comments
 (0)