Skip to content

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

Merged
merged 6 commits into from
Feb 8, 2019

Conversation

BrennanConroy
Copy link
Member

Fixes #7157

Copy link
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TS functional test that uses msgpack with cancel.

@BrennanConroy
Copy link
Member Author

Unfortunately there is no good way in the functional tests to test that it actually did anything. Unless I do some ugly stuff with using the IHubContext<THub> to send a message to the client when the streaming cancellation occurs.

@Eilon Eilon added the area-signalr Includes: SignalR clients and servers label Feb 4, 2019
@halter73
Copy link
Member

halter73 commented Feb 4, 2019

Unfortunately there is no good way in the functional tests to test that it actually did anything. Unless I do some ugly stuff with using the IHubContext to send a message to the client when the streaming cancellation occurs.

Is the "can stream server method and cancel stream" test not verifying this change actually did something?

@BrennanConroy
Copy link
Member Author

It is, but I had to do the IHubContext stuff to make it verify the stream was closed.

@halter73
Copy link
Member

halter73 commented Feb 4, 2019

Fair. It wasn't that ugly.

@BrennanConroy
Copy link
Member Author

It wasn't that ugly.

Opinions

@BrennanConroy
Copy link
Member Author

🆙 📅

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);
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
The test change needed was https://github.com/aspnet/AspNetCore/pull/7224/files#diff-e53c0bba1752f4416da08f9f40b4ac92R1078 to wait for a message since it now goes async.

Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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 expect(connection.sentData.length).toBe(3); check. Now the cancel callback waits until the stream has finished being started before allowing the cancel to be sent.

I think the test is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants