Skip to content

Stream decoders silently accept incomplete final records #299

Open

Description

@HocVoNgThai

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'

const bytes = encode([{ id: 1 }, { id: 2 }])
async function* input() {
  yield bytes.subarray(0, bytes.length - 1)
}

const items = []
for await (const item of decodeArrayStream(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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions