Skip to content

Commit

Permalink
test: resolve race condition in test-net-write-fully-async-*
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #57022
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
  • Loading branch information
mcollina authored Feb 25, 2025
1 parent d62d7ca commit 9840ca3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions test/parallel/test-net-write-fully-async-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const data = Buffer.alloc(1000000);

const server = net.createServer(common.mustCall(function(conn) {
conn.resume();
server.close();
})).listen(0, common.mustCall(function() {
const conn = net.createConnection(this.address().port, common.mustCall(() => {
let count = 0;

function writeLoop() {
if (count++ === 200) {
conn.destroy();
server.close();
if (count++ === 20) {
conn.end();
return;
}

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-net-write-fully-async-hex-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const data = Buffer.alloc(1000000).toString('hex');

const server = net.createServer(common.mustCall(function(conn) {
conn.resume();
server.close();
})).listen(0, common.mustCall(function() {
const conn = net.createConnection(this.address().port, common.mustCall(() => {
let count = 0;

function writeLoop() {
if (count++ === 20) {
conn.destroy();
server.close();
conn.end();
return;
}

Expand Down

0 comments on commit 9840ca3

Please sign in to comment.