@abraca/dabra 0.4.0 → 0.5.0
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/AbracadabraProvider.ts +6 -23
package/package.json
CHANGED
|
@@ -417,29 +417,12 @@ export class AbracadabraProvider extends HocuspocusProvider {
|
|
|
417
417
|
private async _doLoadChild(childId: string): Promise<AbracadabraProvider> {
|
|
418
418
|
const childDoc = new Y.Doc({ guid: childId });
|
|
419
419
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const onRegistered = ({ childId: cid }: onSubdocRegisteredParameters) => {
|
|
427
|
-
if (cid === childId) {
|
|
428
|
-
this.off("subdocRegistered", onRegistered);
|
|
429
|
-
resolve();
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
this.on("subdocRegistered", onRegistered);
|
|
433
|
-
this.registerSubdoc(childDoc);
|
|
434
|
-
// Fallback: don't block forever if the server is slow or the
|
|
435
|
-
// doc was already registered in a previous session.
|
|
436
|
-
setTimeout(resolve, 3000);
|
|
437
|
-
});
|
|
438
|
-
} else {
|
|
439
|
-
// Offline: queue the registration for replay on reconnect and proceed
|
|
440
|
-
// immediately so the child provider can populate from its local store.
|
|
441
|
-
this.registerSubdoc(childDoc);
|
|
442
|
-
}
|
|
420
|
+
// Fire-and-forget: tell the server this child belongs to the parent.
|
|
421
|
+
// The child provider's own WebSocket handshake (TCP + TLS + auth) is
|
|
422
|
+
// slow enough that the server will have processed the registration
|
|
423
|
+
// before the child's first SyncStep1 arrives. In the rare race the
|
|
424
|
+
// child's built-in reconnect logic retries automatically.
|
|
425
|
+
this.registerSubdoc(childDoc);
|
|
443
426
|
|
|
444
427
|
// Each child gets its own WebSocket connection. Omitting
|
|
445
428
|
// websocketProvider lets HocuspocusProvider create one automatically
|