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 — test: improve test-net-server-pause-on-connect · nodejs/node@b60e690

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-net-server-pause-on-connect.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-net-server-pause-on-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-net-server-pause-on-connect.js
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ var server1 = net.createServer({pauseOnConnect: true}, function(socket) {
1616
});
1717

1818
setTimeout(function() {
19+
// After 50(ish) ms, the other socket should have already read the data.
20+
assert.equal(read, true);
1921
assert.equal(socket.bytesRead, 0, 'no data should have been read yet');
22+
2023
socket.resume();
2124
stopped = false;
22-
}, 3000);
25+
}, common.platformTimeout(50));
2326
});
2427

28+
// read is a timing check, as server1's timer should fire after server2's
29+
// connection receives the data. Note that this could be race-y.
30+
var read = false;
2531
var server2 = net.createServer({pauseOnConnect: false}, function(socket) {
2632
socket.on('data', function(data) {
33+
read = true;
34+
2735
assert.equal(data.toString(), msg, 'invalid data received');
2836
socket.end();
2937
server2.close();
@@ -37,3 +45,8 @@ server1.listen(common.PORT, function() {
3745
server2.listen(common.PORT + 1, function() {
3846
net.createConnection({port: common.PORT + 1}).write(msg);
3947
});
48+
49+
process.on('exit', function() {
50+
assert.equal(stopped, false);
51+
assert.equal(read, true);
52+
});

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.