From bf9a824c0a4d7a2c96cd89631f8422c359500b68 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 7 Dec 2019 14:20:02 +0100 Subject: [PATCH] test: wait for stream close before writing to file 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: https://github.com/nodejs/node/pull/30836 Fixes: https://github.com/nodejs/node/issues/30660 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Ben Noordhuis --- .../parallel/test-readline-async-iterators-destroy.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-readline-async-iterators-destroy.js b/test/parallel/test-readline-async-iterators-destroy.js index 746981a1ae7cfd..e96f831432b1eb 100644 --- a/test/parallel/test-readline-async-iterators-destroy.js +++ b/test/parallel/test-readline-async-iterators-destroy.js @@ -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'); @@ -42,6 +43,11 @@ async function testSimpleDestroy() { expectedLines.splice(1); assert.deepStrictEqual(iteratedLines, expectedLines); + + rli.close(); + readable.destroy(); + + await once(readable, 'close'); } } @@ -72,6 +78,11 @@ async function testMutualDestroy() { } assert.deepStrictEqual(iteratedLines, expectedLines); + + rli.close(); + readable.destroy(); + + await once(readable, 'close'); } }