Skip to content

Commit

Permalink
test: fix flaky test-http2-reset-flood
Browse files Browse the repository at this point in the history
Move boolean check to start of writeRequest() to avoid race condition.

Fixes: nodejs#29802
  • Loading branch information
Trott committed Jul 9, 2020
1 parent 99f0404 commit b5e0943
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/parallel/test-http2-reset-flood.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ const worker = new Worker(__filename).on('message', common.mustCall((port) => {
let streamId = 1;

function writeRequests() {
if (gotError)
return;

console.log(`Trying writeRequests at ${new Date().toLocaleString()}.`);

for (let i = 1; i < 10 && !gotError; i++) {
h2header[3] = 1; // HEADERS
h2header[4] = 0x5; // END_HEADERS|END_STREAM
Expand All @@ -78,6 +83,7 @@ const worker = new Worker(__filename).on('message', common.mustCall((port) => {
}

conn.once('error', common.mustCall(() => {
console.log(`Expected error received at ${new Date().toLocaleString()}.`);
gotError = true;
worker.terminate();
conn.destroy();
Expand Down

0 comments on commit b5e0943

Please sign in to comment.