Skip to content

NIOTestUtils.ByteToMessageDecoderVerifier fails too early #3414

@MahdiBM

Description

@MahdiBM

See #3411 (comment) for the origin of this issue.

Expected behavior

The behavior described below should not happen.

Actual behavior

It [ByteToMessageDecoderVerifier.verifyDecoder] fails with "under production" error when it calls channel.readInbound(as:) and that returns nil, but it should call channel.finish() at that point so it gets the last result and everything matches up.
The split-decoder needs to have been called with decodeLast (so channel.finish()), if it's going to return whatever is left in the buffer, when the buffer doesn't contain any separators anymore. If it's called with just decode, it'll return nil to request more data, which is correct behavior.

Steps to reproduce

See the commit in that PR, which I reverted.
mahdibm/swift-nio, tag byte2msgverifier-fails-too-early.
There is a [0...0] in there which was just for my testing. The tests fail anyway even with that so doesn't really matter.

If possible, minimal yet complete reproducer code (or URL to code)

See above.

SwiftNIO version/commit hash

Building on top of commit 767ea9ee09c4227d32f230c7e24bb9f5a6a5cfd9. So after 2.87.0.

System & version information

Doesn't matter.

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