Skip to content

Fix cleaning send queue on restart #18511

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 2 commits into from
Jan 24, 2020
Merged

Fix cleaning send queue on restart #18511

merged 2 commits into from
Jan 24, 2020

Conversation

BrennanConroy
Copy link
Member

Fixes #17613

Also slipped in a couple other minor fixups:

  • Updated karma-firefox-launcher so that it would actually close the browser on test exit (I had dozens of firefox instances open from running the functional tests a bunch of times)
  • Added an abort signal check in NodeHttpClient to fix a race between the LongPolling transport being closed and re-polling. (the race would only show up in tests since product code uses the DefaultHttpClient which already has the check)
  • Changed some cleanup code in WebSocketTransport so we actually close the connection due to an "internal error". Such as throwing while parsing a message from the server.

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Jan 22, 2020
@BrennanConroy BrennanConroy added this to the 5.0.0-preview1 milestone Jan 22, 2020
tryAddBrowser("ChromiumHeadlessIgnoreCert", new ChromiumHeadlessBrowser(() => { }, {}));
if (!tryAddBrowser("FirefoxHeadless", new FirefoxHeadlessBrowser(0, () => { }, {}))) {
tryAddBrowser("FirefoxDeveloperHeadless", new FirefoxDeveloperHeadlessBrowser(0, () => { }, {}));
tryAddBrowser("ChromeHeadlessNoSandbox", ChromeHeadlessBrowser.prototype);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is part of updating the firefox launcher. We shouldn't have been instantiating these classes to check if the browsers exists.

tryAddBrowser("Edge", new EdgeBrowser(() => { }, { create() { } }));
tryAddBrowser("IE", new IEBrowser(() => { }, { create() { } }, {}));
tryAddBrowser("Safari", new SafariBrowser(() => { }, {}));
tryAddBrowser("Edge", EdgeBrowser.prototype);
Copy link
Contributor

Choose a reason for hiding this comment

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

Which edge is this testing? Legacy?

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH we need to do some work to understand what Karma does locally and what Sauce Labs will do in the cloud. I'll file a bug for that.

For now, I'd expect yes, it's Edge Legacy.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -43,21 +43,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.49.tgz#ab4df6e505db088882c8ce5417ae0bc8cbb7a8a6"
integrity sha512-YY0Okyn4QXC4ugJI+Kng5iWjK8A6eIHiQVaGIhJkyn0YL6Iqo0E0tBC8BuhvYcBK87vykBijM5FtMnCqaa5anA==

"@types/strip-bom@^3.0.0":
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you referring to the file changing? Yes, I updated dependencies so this file gets updated.

return this._onopen!;
return (e) => {
this._onopen!(e);
this.readyState = this.OPEN;
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is readyState used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Used by the WebSocketTransport

this.webSocket.onerror = () => {};
this.webSocket.close();
this.webSocket = undefined;
this.cleanup();
Copy link
Member

Choose a reason for hiding this comment

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

Nit: close() also calls cleanup(), and close() is called immediately after this. I'd just remove cleanup() and put the logic directly in close().

});
this.sendQueue = undefined;
}

Copy link
Member

Choose a reason for hiding this comment

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

While we're cleaning up random things, can we move the this.connectionStarted = false; above the if (this.onclose && this.connectionStarted) {? I wrote it that way, but don't know why. It shouldn't be dependent on whether the onclose callback was hooked. Thankfully, HubConnection always does hook the onclose callback, but still.

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved the if (this.onclose) check instead. We don't want to run the onclose function if the connection never started.

Copy link
Member

Choose a reason for hiding this comment

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

We don't want to run the onclose function if the connection never started.

Yeah. That's the whole point of that logic. We don't need to check if connectionStarted is true in order to set it to false. Both ways work, but it does seem a little weird to put the if block inside the try block.

@BrennanConroy BrennanConroy merged commit b375410 into master Jan 24, 2020
@BrennanConroy BrennanConroy deleted the brecon/sendqueue branch January 24, 2020 21:26
dougbu pushed a commit that referenced this pull request May 18, 2020
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.

Hub handshake failed with error 'WebSocket is not in the OPEN state' SignalR WebSockets Angular client with AutoReconnect()
4 participants