js-libp2p
js-libp2p copied to clipboard
[email protected] does not support chunks bigger than 2Mb anymore
- Version: [email protected] (vs [email protected])
- Platform: Windows + node v16.13.2
- Subsystem: @libp2p/mplex? (to be confirmed)
Severity:
Low
Description:
When receiving chunks of data bigger than 2Mb from a stream, Error: message size too large! errors are raised,
while with [email protected], we could exchange chunks of 10Mb at least.
Not really an operational problem I guess. Quick workarounds easy to set up. But depending on the root cause, I can't say on my own whether that problem could hide a bigger one.
Steps to reproduce the error:
Using the scripts attached with #1342, launch the sender (3145728 = 3 * 1024 * 1024):
node libp2p-node.0.37.x.mjs --send=path-to-a-big-file --size=3145728
then launch the receiver:
node libp2p-node.0.37.x.mjs --connect=/address/of/sender/node
Error displayed by the receiver:
file:///.../node_modules/@libp2p/mplex/dist/src/restrict-size.js:14
throw Object.assign(new Error('message size too large!'), { code: 'ERR_MSG_TOO_BIG' });
^
Error: message size too large!
at checkSize (file:///.../node_modules/@libp2p/mplex/dist/src/restrict-size.js:14:33)
at Array.forEach (<anonymous>)
at restrictSize (file:///.../node_modules/@libp2p/mplex/dist/src/restrict-size.js:21:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async file:///.../node_modules/@libp2p/mplex/dist/src/mplex.js:134:38
at async MplexStreamMuxer.sink (file:///.../node_modules/@libp2p/mplex/dist/src/mplex.js:133:17) {
code: 'ERR_MSG_TOO_BIG'
}
For the info, I came up through this while measuring the impact of chunk sizes on transfer rates, which gave me the graph below:

We can see on this graph that orange dots ([email protected]) stop at 2Mb, while blue dots go up to 10Mb.
You scripts are initializing Mplex with default max message size value, you should set it to something higher: https://github.com/libp2p/js-libp2p-mplex/blob/v1.1.2/src/index.ts#L11
@Alexis-ROYER
Thanks for the info @mpetrunic.
To compare with the Mplex coming along with [email protected] ([email protected] on my side):
- I guess it means that the default max message size was different?
- Or possibly this max message size limit did not exist?
Not sure honestly. maybe something was overriding that limit