11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 51cb0ef41Sopenharmony_ciconst { strictEqual } = require('assert'); 61cb0ef41Sopenharmony_ciconst fs = require('fs'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/51993 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_citmpdir.refresh(); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst file = tmpdir.resolve('test-fs-writestream-open-write.txt'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst w = fs.createWriteStream(file); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciw.on('open', common.mustCall(() => { 171cb0ef41Sopenharmony_ci w.write('hello'); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci process.nextTick(() => { 201cb0ef41Sopenharmony_ci w.write('world'); 211cb0ef41Sopenharmony_ci w.end(); 221cb0ef41Sopenharmony_ci }); 231cb0ef41Sopenharmony_ci})); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciw.on('close', common.mustCall(() => { 261cb0ef41Sopenharmony_ci strictEqual(fs.readFileSync(file, 'utf8'), 'helloworld'); 271cb0ef41Sopenharmony_ci fs.unlinkSync(file); 281cb0ef41Sopenharmony_ci})); 29