mirror of https://github.com/rails/rails
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:
parent
bad8e77335
commit
ed8e767218
|
@ -166,7 +166,7 @@
|
|||
if (!allowReconnect) {
|
||||
this.monitor.stop();
|
||||
}
|
||||
if (this.isActive()) {
|
||||
if (this.isOpen()) {
|
||||
return this.webSocket.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ class Connection {
|
|||
if (!allowReconnect) {
|
||||
this.monitor.stop();
|
||||
}
|
||||
if (this.isActive()) {
|
||||
if (this.isOpen()) {
|
||||
return this.webSocket.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
if (!allowReconnect) {
|
||||
this.monitor.stop();
|
||||
}
|
||||
if (this.isActive()) {
|
||||
if (this.isOpen()) {
|
||||
return this.webSocket.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue