Merged
Conversation
willportnoy
reviewed
Dec 5, 2020
|
|
||
| // RxJS.retryWhen has a bug that would cause "error" signal to be sent after the observable is completed/errored. | ||
| // We need to guard against extraneous "error" signal to workaround the bug. | ||
| closed || subscriber.error(close); |
Member
There was a problem hiding this comment.
error [](start = 37, length = 5)
normal web socket close should lead to non-error RX stream completion, right?
Collaborator
Author
There was a problem hiding this comment.
I am keeping the original logic as-is, i.e. onclose will throw an error. And I think it's intentional.
If you look at line 910,
BotFramework-DirectLineJS/src/directLine.ts
Line 912 in 6fc932d
this.observableWebSocket<ActivityGroup>()
// WebSockets can be closed by the server or the browser. In the former case we need to
// retrieve a new streamUrl. In the latter case we could first retry with the current streamUrl,
// but it's simpler just to always fetch a new one.
.retryWhen(error$ => error$.delay(this.getRetryDelay(), this.services.scheduler).mergeMap(error => this.reconnectToConversation()))
Looks like the author of the logic intentionally want to retry whenever the server or browser close the connection. And to do that, the code need to throw error on graceful close.
What do you think?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reintroducing PR #170 and workarounding RxJS issue.
There is a bug in RxJS
retryWhenoperator that caused observable to be re-subscribed more than once, after only one error is raised. That means, the RxJS bug could cause one error to trigger reconnect twice.We wrote a test case that:
Without
onerrorWithin 2 seconds, we are seeing 88 errors injected, and 88 reconnections.
With
onerrorWithin 2 seconds, we are seeing 767 errors injected, and 1023 reconnections.
Takeaways:
To mitigate, we manually added a flag
closed. This flag guardobserver.error()will only be called once. We believe if itobserver.error()is called twice (byonerror, followed byoncloseevent),retryWhencould triggered retry twice (or more).We added a test case to make sure all numbers are under control in the future.