Skip to content

Commit 20c032e

Browse files
mcollinaaduh95
authored andcommitted
test: resolve race condition in test-net-write-fully-async-*
Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #57022 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 3d103ec commit 20c032e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/parallel/test-net-write-fully-async-buffer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ const data = Buffer.alloc(1000000);
1111

1212
const server = net.createServer(common.mustCall(function(conn) {
1313
conn.resume();
14+
server.close();
1415
})).listen(0, common.mustCall(function() {
1516
const conn = net.createConnection(this.address().port, common.mustCall(() => {
1617
let count = 0;
1718

1819
function writeLoop() {
19-
if (count++ === 200) {
20-
conn.destroy();
21-
server.close();
20+
if (count++ === 20) {
21+
conn.end();
2222
return;
2323
}
2424

test/parallel/test-net-write-fully-async-hex-string.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ const data = Buffer.alloc(1000000).toString('hex');
99

1010
const server = net.createServer(common.mustCall(function(conn) {
1111
conn.resume();
12+
server.close();
1213
})).listen(0, common.mustCall(function() {
1314
const conn = net.createConnection(this.address().port, common.mustCall(() => {
1415
let count = 0;
1516

1617
function writeLoop() {
1718
if (count++ === 20) {
18-
conn.destroy();
19-
server.close();
19+
conn.end();
2020
return;
2121
}
2222

0 commit comments

Comments
 (0)