From 0e5066e7a279f23fad80cd97a9abadb7a8f27f56 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 28 May 2020 21:03:49 +0200 Subject: [PATCH] test: fix flaky fs-construct test Fixes: https://github.com/nodejs/node/issues/33607 --- test/parallel/test-fs-stream-construct.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-stream-construct.js b/test/parallel/test-fs-stream-construct.js index 4e6bf0285fc91e..4e687838f6b0c8 100644 --- a/test/parallel/test-fs-stream-construct.js +++ b/test/parallel/test-fs-stream-construct.js @@ -199,11 +199,14 @@ const examplePath = fixtures.path('x.txt'); }); }); - const w = new WriteStream(`${tmpdir.path}/dummy2`, - { flags: 'wx+', emitClose: true }) - .on('error', common.mustCall((err) => { - assert.strictEqual(err.code, 'EEXIST'); - w.destroy(); - w.on('close', common.mustCall()); - })); + fs.open(`${tmpdir.path}/dummy3`, 'wx+', common.mustCall((err) => { + assert(!err); + const w = new WriteStream(`${tmpdir.path}/dummy3`, + { flags: 'wx+', emitClose: true }) + .on('error', common.mustCall((err) => { + assert.strictEqual(err.code, 'EEXIST'); + w.destroy(); + w.on('close', common.mustCall()); + })); + })); }