1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Only close websockets when connection is open (#44304)

This addresses a problem where Safari's websockets gets permanently broken
when closing them in a "connecting" state.

See https://github.com/rails/rails/issues/43835#issuecomment-1002288478
This commit is contained in:
Jorge Manrubia 2022-02-02 15:50:34 +01:00 committed by GitHub
parent bad8e77335
commit ed8e767218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View file

@ -166,7 +166,7 @@
if (!allowReconnect) {
this.monitor.stop();
}
if (this.isActive()) {
if (this.isOpen()) {
return this.webSocket.close();
}
}

View file

@ -172,7 +172,7 @@ class Connection {
if (!allowReconnect) {
this.monitor.stop();
}
if (this.isActive()) {
if (this.isOpen()) {
return this.webSocket.close();
}
}

View file

@ -166,7 +166,7 @@
if (!allowReconnect) {
this.monitor.stop();
}
if (this.isActive()) {
if (this.isOpen()) {
return this.webSocket.close();
}
}

View file

@ -44,7 +44,8 @@ class Connection {
close({allowReconnect} = {allowReconnect: true}) {
if (!allowReconnect) { this.monitor.stop() }
if (this.isActive()) {
// Avoid closing websockets in a "connecting" state due to Safari 15.1+ bug. See: https://github.com/rails/rails/issues/43835#issuecomment-1002288478
if (this.isOpen()) {
return this.webSocket.close()
}
}