Skip to content

Commit a70d921

Browse files
committed
fix: improve resilience to conectivity issues
1 parent b356e22 commit a70d921

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/store/pnp.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ const actions = {
293293
*/
294294
async [PNP_SERVICE_CONNECT] ({ state, commit, dispatch }) {
295295
// if connection to pnp service already open, then nothing to do
296-
if (peer && peer.open) return
296+
if (peer && peer.open) { return }
297+
// if in the middle of pnp server connection cycle, skip
298+
if (state.pnpServiceConnectionStatus === PNP_SERVICE_CONNECTING) { return }
297299
// Create own peer object with connection to shared PeerJS server
298300
console.log('pnp client: creating peer')
299301
// If we already have an assigned peerId, we will reuse it forever.
@@ -320,6 +322,8 @@ const actions = {
320322
async [PNP_SERVICE_RECONNECT] ({ state, commit, dispatch }) {
321323
// if connection to pnp service already open, then nothing to do
322324
if (peer.open) return
325+
// if in the middle of pnp server connection cycle, skip
326+
if (state.pnpServiceConnectionStatus === PNP_SERVICE_CONNECTING) { return }
323327
console.log('pnp client: reconnecting peer...')
324328
// Workaround for peer.reconnect deleting previous id
325329
if (!peer.id) {

0 commit comments

Comments
 (0)