diff --git a/test/simple/test-net-pipe-connect-errors.js b/test/simple/test-net-pipe-connect-errors.js index e29d50e73e3abe..07dd4fe4a2bb75 100644 --- a/test/simple/test-net-pipe-connect-errors.js +++ b/test/simple/test-net-pipe-connect-errors.js @@ -42,19 +42,20 @@ if (process.platform === 'win32') { // use common.PIPE to ensure we stay within POSIX socket path length // restrictions, even on CI emptyTxt = common.PIPE + '.txt'; -} -function cleanup() { - try { - fs.unlinkSync(emptyTxt); - } catch (e) { - if (e.code != 'ENOENT') - throw e; + function cleanup() { + try { + fs.unlinkSync(emptyTxt); + } catch (e) { + if (e.code != 'ENOENT') + throw e; + } } + process.on('exit', cleanup); + cleanup(); + fs.writeFileSync(emptyTxt, ''); } -process.on('exit', cleanup); -cleanup(); -fs.writeFileSync(emptyTxt, ''); + var notSocketClient = net.createConnection(emptyTxt, function() { assert.ok(false); });