@decentnetwork/peer 0.1.21 → 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.
Files changed (2) hide show
  1. package/dist/peer.js +15 -1
  2. package/package.json +1 -1
package/dist/peer.js CHANGED
@@ -768,6 +768,7 @@ export class Peer {
768
768
  return;
769
769
  }
770
770
  catch (error) {
771
+ const emsg = error.message;
771
772
  // Mirrors Carrier C SDK behavior: when an in-session send fails
772
773
  // (no transport accepted the encrypted packet), fall through to
773
774
  // the express offline relay rather than dropping the message
@@ -775,7 +776,20 @@ export class Peer {
775
776
  // express pull. Without this the message is just lost when the
776
777
  // friend's NAT briefly forgets us — observed when iPad rebinds
777
778
  // its TCP relay slot, or when UDP and TCP relay both blip.
778
- this.#debugLog(`sendText: in-session send failed for ${pubkey}, falling back to express: ${error.message}`);
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}`);
779
793
  }
780
794
  }
781
795
  // Offline / fallback path via Carrier express HTTP store-and-forward.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.21",
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",