GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: add no-half-open enforcer only if needed · nodejs/node@9c0c0e6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _stream_duplex.js
  • test/parallel
    • test-stream-duplex.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_stream_duplex.js‎

Copy file name to clipboardExpand all lines: lib/_stream_duplex.js
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ function Duplex(options) {
5858
this.writable = false;
5959

6060
this.allowHalfOpen = true;
61-
if (options && options.allowHalfOpen === false)
61+
if (options && options.allowHalfOpen === false) {
6262
this.allowHalfOpen = false;
63-
64-
this.once('end', onend);
63+
this.once('end', onend);
64+
}
6565
}
6666

6767
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
@@ -96,9 +96,8 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
9696

9797
// the no-half-open enforcer
9898
function onend() {
99-
// if we allow half-open state, or if the writable side ended,
100-
// then we're ok.
101-
if (this.allowHalfOpen || this._writableState.ended)
99+
// If the writable side ended, then we're ok.
100+
if (this._writableState.ended)
102101
return;
103102

104103
// no more data can be written.
Collapse file

‎test/parallel/test-stream-duplex.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-duplex.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const stream = new Duplex({ objectMode: true });
2929
assert(Duplex() instanceof Duplex);
3030
assert(stream._readableState.objectMode);
3131
assert(stream._writableState.objectMode);
32+
assert(stream.allowHalfOpen);
33+
assert.strictEqual(stream.listenerCount('end'), 0);
3234

3335
let written;
3436
let read;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.