@jcbuisson/express-x-client 3.1.10 → 3.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client.mts +14 -3
package/package.json
CHANGED
package/src/client.mts
CHANGED
|
@@ -26,7 +26,11 @@ export function createClient(socket, options={}) {
|
|
|
26
26
|
socket.on("connect", async () => {
|
|
27
27
|
if (options.debug) console.log("socket connected", socket.id)
|
|
28
28
|
for (const func of connectListeners) {
|
|
29
|
-
|
|
29
|
+
try {
|
|
30
|
+
await func(socket)
|
|
31
|
+
} catch(err) {
|
|
32
|
+
console.error('connect listener error', err)
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
})
|
|
32
36
|
|
|
@@ -369,8 +373,14 @@ export function offlinePlugin(app) {
|
|
|
369
373
|
app.connectedDate = new Date()
|
|
370
374
|
console.log('onConnect', app.connectedDate)
|
|
371
375
|
app.isConnected = true
|
|
372
|
-
|
|
373
|
-
|
|
376
|
+
const disconnectedDate = app.disconnectedDate
|
|
377
|
+
if (disconnectedDate) {
|
|
378
|
+
const results = await Promise.allSettled(modelSyncFunctions.map(sync => sync()))
|
|
379
|
+
const failures = results.filter(result => result.status === 'rejected')
|
|
380
|
+
if (failures.length > 0) {
|
|
381
|
+
console.error('err reconnect synchronizeAll', failures.map(result => result.reason))
|
|
382
|
+
return
|
|
383
|
+
}
|
|
374
384
|
}
|
|
375
385
|
app.disconnectedDate = null
|
|
376
386
|
})
|
|
@@ -483,6 +493,7 @@ export function offlinePlugin(app) {
|
|
|
483
493
|
}
|
|
484
494
|
} catch(err) {
|
|
485
495
|
console.log('err synchronize', modelName, where, err)
|
|
496
|
+
throw err
|
|
486
497
|
} finally {
|
|
487
498
|
mutex.release()
|
|
488
499
|
}
|