@decentnetwork/peer 0.1.20 → 0.1.22
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/dist/peer.js +17 -2
- package/dist/store/friends.d.ts +4 -0
- package/package.json +1 -1
package/dist/peer.js
CHANGED
|
@@ -723,7 +723,8 @@ export class Peer {
|
|
|
723
723
|
address,
|
|
724
724
|
nospam,
|
|
725
725
|
hello: hello ?? existing?.hello,
|
|
726
|
-
status: existing?.status ?? "requested"
|
|
726
|
+
status: existing?.status ?? "requested",
|
|
727
|
+
requestedAt: existing?.requestedAt ?? Date.now()
|
|
727
728
|
});
|
|
728
729
|
this.#persistFriends();
|
|
729
730
|
// Tell every connected TCP relay we want this friend routed; the
|
|
@@ -767,6 +768,7 @@ export class Peer {
|
|
|
767
768
|
return;
|
|
768
769
|
}
|
|
769
770
|
catch (error) {
|
|
771
|
+
const emsg = error.message;
|
|
770
772
|
// Mirrors Carrier C SDK behavior: when an in-session send fails
|
|
771
773
|
// (no transport accepted the encrypted packet), fall through to
|
|
772
774
|
// the express offline relay rather than dropping the message
|
|
@@ -774,7 +776,20 @@ export class Peer {
|
|
|
774
776
|
// express pull. Without this the message is just lost when the
|
|
775
777
|
// friend's NAT briefly forgets us — observed when iPad rebinds
|
|
776
778
|
// its TCP relay slot, or when UDP and TCP relay both blip.
|
|
777
|
-
|
|
779
|
+
//
|
|
780
|
+
// EXCEPT a "payload too big" failure (>1373 bytes), which is
|
|
781
|
+
// PERMANENT, not transient: it fails identically every retry, so
|
|
782
|
+
// queuing it to express just piles undeliverable oversized blobs
|
|
783
|
+
// into the recipient's offline queue. A dora's oversized roster
|
|
784
|
+
// reply re-sent every 60s produced a 69k-message backlog that made
|
|
785
|
+
// every pull time out — starving real friend-requests. Oversized
|
|
786
|
+
// payloads must be chunked by the caller (the dora now paginates),
|
|
787
|
+
// not flooded through express; drop to the caller instead.
|
|
788
|
+
if (/1\.\.1373 bytes|payload must be 1/i.test(emsg)) {
|
|
789
|
+
this.#debugLog(`sendText: oversized payload for ${pubkey} (${emsg}) — NOT queuing to express (would flood); caller must chunk`);
|
|
790
|
+
throw error;
|
|
791
|
+
}
|
|
792
|
+
this.#debugLog(`sendText: in-session send failed for ${pubkey}, falling back to express: ${emsg}`);
|
|
778
793
|
}
|
|
779
794
|
}
|
|
780
795
|
// Offline / fallback path via Carrier express HTTP store-and-forward.
|
package/dist/store/friends.d.ts
CHANGED
|
@@ -9,5 +9,9 @@ export type FriendRecord = {
|
|
|
9
9
|
remoteHost?: string;
|
|
10
10
|
remotePort?: number;
|
|
11
11
|
hello?: string;
|
|
12
|
+
/** When we sent the outbound friend request (ms epoch). Set once, even
|
|
13
|
+
* while status stays "requested", so UIs can show how long a request
|
|
14
|
+
* has been pending. */
|
|
15
|
+
requestedAt?: number;
|
|
12
16
|
acceptedAt?: number;
|
|
13
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/peer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Pure TypeScript port of Elastos Carrier (toxcore-derived) P2P messaging. DHT, onion routing, TCP relay, FlatBuffers app payloads, Express offline relay. Wire-compatible with iOS Beagle and the Carrier C SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|