Skip to content

libp2p/gossipsub: If the message size exceeds 4MB, the transmission will fail. #3427

Description

@XhstormR
  • Version:
        "@libp2p/circuit-relay-v2": "^4.1.7",
        "@libp2p/gossipsub": "^15.0.16",
        "@libp2p/identify": "^4.0.14",
        "@libp2p/ping": "^3.0.14",
        "@libp2p/webrtc": "^6.0.15",
        "@libp2p/websockets": "^10.1.7",
        "libp2p": "^3.1.7",
  • Platform:

Darwin l3xkxytj3q 25.4.0 Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:25 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6041 arm64 Darwin

Google Chrome 146.0.7680.165

  • Subsystem:

@libp2p/gossipsub

Severity:

High

Description:

Use pubsub.publish(topic, payload) to send a message. If the message size exceeds 4MB, the transmission will fail. No option or config provided to control the maximum message size.

Steps to reproduce the error:

        const fileBytes = new Uint8Array(await file.arrayBuffer());
        const payload = new Uint8Array(1 + fileBytes.length);
        payload[0] = 1;
        payload.set(fileBytes, 1);
        await this.libp2p!.services.pubsub.publish(topic, payload);

error log:

Uncaught (in promise) InvalidDataLengthError: Message length too long
    at validateMaxDataLength (chunk-WH3I752V.js?v=f459f200:254:11)
    at encode2.single (chunk-WH3I752V.js?v=f459f200:300:3)
    at OutboundStream.push (@libp2p_gossipsub.js?v=f459f200:5980:37)
    at @chainsafe/libp2p-gossipsub.sendRpc (@libp2p_gossipsub.js?v=f459f200:8007:22)
    at @chainsafe/libp2p-gossipsub.publish (@libp2p_gossipsub.js?v=f459f200:7859:27)
    at async Module.track_reactivity_loss (chunk-LJCYD6UY.js?v=f459f200:1639:15)
    at async Libp2pStore.sendFile (p2p-store.svelte.ts:191:33)
    at async Module.track_reactivity_loss (chunk-LJCYD6UY.js?v=f459f200:1639:15)
    at async HTMLButtonElement.sendMessage (ChatArea.svelte:31:26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions