Skip to content

net: don't explicitly set readable/writable

net.Socket is slightly breaking stream invariants by having readable/writable going from false to true. Streams assume that readable/writable starts out true and then goes to false through push(null)/end() after which it never goes back to true, e.g. once a stream is writable == false it is assumed it will never become true.

This PR changes 2 things:

Unless explicitly set to false through options:

  • starts as readable/writable true by default.
  • uses push(null)/end() to set readable/writable to false. Note that this would cause the socket to emit the 'end'/'finish' events, which it did not do previously.

In the case it is explicitly set to false through options it is assumed to never become true.

This makes net behave like regular streams and the way quic currently handles the corresponding functionality.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading