msgpack5 uses instanceof require('bl') to check if it's argument is a BufferList which will return false if the consumer resolves a different bl package. This happens when msgpack5 and the consumer depend on different versions of bufferlist.
node_modules/
bl/ , require('bl') in consumer code
msgpack5/
node_modules/
bl/ <- require('bl') in msgpack5 code
When I upgraded my applications bl to 5 tests started failing because the BufferList passed to decode was not consumed.
const { decode, encode } = require('msgpack5')()
const bl = new BufferList([encode(0), encode(1), encode(2)])
assert(bl.length === 3)
decode(bl)
// fails after upgrading to bl@5.
assert(bl.length === 2)
I have a few suggestions
move bl to a peer dependency
use bl@5's BufferList.isBufferList method which uses a symbol on the bl instance and should work across versions.
msgpack5 has a dependency on bl@^4.0.0 If a msgpack5 consumer passes a
BufferList
from a differentbl
modulehttps://github.com/mcollina/msgpack5/blob/master/lib/decoder.js#L45-L48
msgpack5 uses
instanceof require('bl')
to check if it's argument is a BufferList which will return false if the consumer resolves a differentbl
package. This happens when msgpack5 and the consumer depend on different versions of bufferlist.When I upgraded my applications
bl
to 5 tests started failing because the BufferList passed to decode was not consumed.I have a few suggestions
bl
to a peer dependencyBufferList.isBufferList
method which uses a symbol on the bl instance and should work across versions.