You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stream decoders silently accept incomplete final records #299
decodeArrayStream() and decodeMultiStream() finish successfully when input ends partway through the last record. The caller receives only the preceding records, although both APIs document a RangeError for incomplete data.
import{encode,decodeArrayStream}from'@msgpack/msgpack'constbytes=encode([{id: 1},{id: 2}])asyncfunction*input(){yieldbytes.subarray(0,bytes.length-1)}constitems=[]forawait(constitemofdecodeArrayStream(input()))items.push(item)console.log(items)// [{ id: 1 }], with no error
Expected: iteration rejects with RangeError when the stream ends. The same issue occurs with concatenated records passed to decodeMultiStream(), and when an array declares another item but contains no bytes for it.
Activity