-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add CancelInvocation support to MsgPack in TS client #7224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
1577a39
2ce65c5
3da4630
0a25866
447df31
36eec3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,13 +156,16 @@ export class HubConnection { | |
const [streams, streamIds] = this.replaceStreamingParams(args); | ||
const invocationDescriptor = this.createStreamInvocation(methodName, args, streamIds); | ||
|
||
let promiseQueue: Promise<void>; | ||
const subject = new Subject<T>(); | ||
subject.cancelCallback = () => { | ||
const cancelInvocation: CancelInvocationMessage = this.createCancelInvocation(invocationDescriptor.invocationId); | ||
|
||
delete this.callbacks[invocationDescriptor.invocationId]; | ||
|
||
return this.sendWithProtocol(cancelInvocation); | ||
return promiseQueue.then(() => { | ||
return this.sendWithProtocol(cancelInvocation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this failed before if you canceled the stream too early. Do we have any regression tests the promiseQueue part of this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The promiseQueue doesn't change with this PR, I just use it somewhere I didn't before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that the promiseQueue existed before. Are you saying that without this change, the "automatically sends multiple pings" would fail? Do you think that's a reliable regression test for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "stream can be canceled" test would fail because TS isn't threaded, so the cancel message wouldn't be sent before getting to the I think the test is good. |
||
}); | ||
}; | ||
|
||
this.callbacks[invocationDescriptor.invocationId] = (invocationEvent: CompletionMessage | StreamItemMessage | null, error?: Error) => { | ||
|
@@ -183,7 +186,7 @@ export class HubConnection { | |
} | ||
}; | ||
|
||
const promiseQueue = this.sendWithProtocol(invocationDescriptor) | ||
promiseQueue = this.sendWithProtocol(invocationDescriptor) | ||
.catch((e) => { | ||
subject.error(e); | ||
delete this.callbacks[invocationDescriptor.invocationId]; | ||
|
Uh oh!
There was an error while loading. Please reload this page.