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 — net: wait for shutdown to complete before closing · nodejs/node@3c8bf90

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • internal
      • stream_base_commons.js
    • net.js
  • test
    • async-hooks
      • test-graph.tls-write.js
    • parallel
      • test-net-allow-half-open.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/stream_base_commons.js‎

Copy file name to clipboardExpand all lines: lib/internal/stream_base_commons.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,16 @@ function onStreamRead(arrayBuffer) {
213213
if (stream[kMaybeDestroy])
214214
stream.on('end', stream[kMaybeDestroy]);
215215

216+
// TODO(ronag): Without this `readStop`, `onStreamRead`
217+
// will be called once more (i.e. after Readable.ended)
218+
// on Windows causing a ECONNRESET, failing the
219+
// test-https-truncate test.
220+
if (handle.readStop) {
221+
const err = handle.readStop();
222+
if (err)
223+
return stream.destroy(errnoException(err, 'read'));
224+
}
225+
216226
// Push a null to signal the end of data.
217227
// Do it before `maybeDestroy` for correct order of events:
218228
// `end` -> `close`
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ function onReadableStreamEnd() {
631631
this.write = writeAfterFIN;
632632
if (this.writable)
633633
this.end();
634-
}
635-
636-
if (!this.destroyed && !this.writable && !this.writableLength)
634+
else if (!this.writableLength)
635+
this.destroy();
636+
} else if (!this.destroyed && !this.writable && !this.writableLength)
637637
this.destroy();
638638
}
639639

Collapse file

‎test/async-hooks/test-graph.tls-write.js‎

Copy file name to clipboardExpand all lines: test/async-hooks/test-graph.tls-write.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ function onexit() {
6565
{ type: 'TCPCONNECTWRAP',
6666
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
6767
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
68-
{ type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' },
69-
{ type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:2' },
70-
{ type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:1' },
68+
{ type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' }
7169
]
7270
);
7371
}
Collapse file

‎test/parallel/test-net-allow-half-open.js‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const net = require('net');
6+
7+
const server = net.createServer(common.mustCall((socket) => {
8+
socket.end(Buffer.alloc(1024));
9+
})).listen(0, common.mustCall(() => {
10+
const socket = net.connect(server.address().port);
11+
assert.strictEqual(socket.allowHalfOpen, false);
12+
socket.resume();
13+
socket.on('end', common.mustCall(() => {
14+
process.nextTick(() => {
15+
// Ensure socket is not destroyed straight away
16+
// without proper shutdown.
17+
assert(!socket.destroyed);
18+
server.close();
19+
});
20+
}));
21+
socket.on('finish', common.mustCall(() => {
22+
assert(!socket.destroyed);
23+
}));
24+
socket.on('close', common.mustCall());
25+
}));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.