Skip to content

writable stream _write and _writev #28408

Closed
@safqwf

Description

@safqwf

Version: v12.4.0 or v10.15.3
Platform: Linux 4.15.0-51-generic #55~16.04.1-Ubuntu SMP Thu May 16 09:24:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Subsystem: Stream Duplex, Object mode, piped into itself.

The documentation says that when I implement _writev method, it will receive chunks of data available in the buffer.

What I actually see is that both _write and _writev methods are used simultaneously.
If _write is fast enough to process the buffer until it fills up to more than one object, then only _write is used. Otherwise, for the first object in the buffer _write will be used, and the rest will be sent to _writev.

Example:

DEBUG: Calling _write with 1
DEBUG: Calling _writev with 15
DEBUG: Calling _write with 1
DEBUG: Pushing null to readable
DEBUG: Calling _writev with 15
DEBUG: Calling _write with 1
DEBUG: Calling _writev with 2
DEBUG: Writable final
DEBUG: _writev 16, _write 16
DEBUG: Read 243, Written 243

Is this an expected behavior? I was assuming that when _writev method is implemented, it will be used exclusively.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions