Skip to content

Commit

Permalink
test: wait for stream close before writing to file
Browse files Browse the repository at this point in the history
Wait for async operations on a file to finish before writing to it
again.

This fixes flakiness in parallel/test-readline-async-iterators-destroy.

PR-URL: #30836
Fixes: #30660
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
addaleax authored and targos committed Jan 14, 2020
1 parent c3daa3e commit bf9a824
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-readline-async-iterators-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const common = require('../common');
const fs = require('fs');
const { once } = require('events');
const { join } = require('path');
const readline = require('readline');
const assert = require('assert');
Expand Down Expand Up @@ -42,6 +43,11 @@ async function testSimpleDestroy() {
expectedLines.splice(1);

assert.deepStrictEqual(iteratedLines, expectedLines);

rli.close();
readable.destroy();

await once(readable, 'close');
}
}

Expand Down Expand Up @@ -72,6 +78,11 @@ async function testMutualDestroy() {
}

assert.deepStrictEqual(iteratedLines, expectedLines);

rli.close();
readable.destroy();

await once(readable, 'close');
}
}

Expand Down

0 comments on commit bf9a824

Please sign in to comment.