mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
fix(sync): do not try to reconnect after end edit (#2412)
We now set the "closeRequested" on the receiver itself, otherwise there is a race condition between the reconnect (which create a new transport) and the onclose checking closeRequest on an old transport.
This commit is contained in:
commit
ebae9a8cd0
2 changed files with 3 additions and 3 deletions
|
@ -61,6 +61,7 @@ export class SyncEngine {
|
||||||
this._reconnectTimeout = null
|
this._reconnectTimeout = null
|
||||||
this._reconnectDelay = RECONNECT_DELAY
|
this._reconnectDelay = RECONNECT_DELAY
|
||||||
this.websocketConnected = false
|
this.websocketConnected = false
|
||||||
|
this.closeRequested = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async authenticate() {
|
async authenticate() {
|
||||||
|
|
|
@ -5,7 +5,6 @@ const FIRST_CONNECTION_TIMEOUT = 2000
|
||||||
export class WebSocketTransport {
|
export class WebSocketTransport {
|
||||||
constructor(webSocketURI, authToken, messagesReceiver) {
|
constructor(webSocketURI, authToken, messagesReceiver) {
|
||||||
this.receiver = messagesReceiver
|
this.receiver = messagesReceiver
|
||||||
this.closeRequested = false
|
|
||||||
|
|
||||||
this.websocket = new WebSocket(webSocketURI)
|
this.websocket = new WebSocket(webSocketURI)
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ export class WebSocketTransport {
|
||||||
this.websocket.addEventListener('message', this.onMessage.bind(this))
|
this.websocket.addEventListener('message', this.onMessage.bind(this))
|
||||||
this.websocket.onclose = () => {
|
this.websocket.onclose = () => {
|
||||||
console.log('websocket closed')
|
console.log('websocket closed')
|
||||||
if (!this.closeRequested) {
|
if (!this.receiver.closeRequested) {
|
||||||
console.log('Not requested, reconnecting...')
|
console.log('Not requested, reconnecting...')
|
||||||
this.receiver.reconnect()
|
this.receiver.reconnect()
|
||||||
}
|
}
|
||||||
|
@ -64,7 +63,7 @@ export class WebSocketTransport {
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.closeRequested = true
|
this.receiver.closeRequested = true
|
||||||
this.websocket.close()
|
this.websocket.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue