We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bee3b36 commit a48c9caCopy full SHA for a48c9ca
2 files changed
lib/internal/streams/destroy.js
@@ -291,7 +291,7 @@ function constructNT(stream) {
291
} else if (err) {
292
errorOrDestroy(stream, err, true);
293
} else {
294
- process.nextTick(emitConstructNT, stream);
+ stream.emit(kConstruct);
295
}
296
297
@@ -304,10 +304,6 @@ function constructNT(stream) {
304
305
306
307
-function emitConstructNT(stream) {
308
- stream.emit(kConstruct);
309
-}
310
-
311
function isRequest(stream) {
312
return stream?.setHeader && typeof stream.abort === 'function';
313
test/parallel/test-fs-writestream-open-write.js
@@ -0,0 +1,28 @@
1
+'use strict';
2
+
3
+const common = require('../common');
4
+const tmpdir = require('../common/tmpdir');
5
+const { strictEqual } = require('assert');
6
+const fs = require('fs');
7
8
+// Regression test for https://github.com/nodejs/node/issues/51993
9
10
+tmpdir.refresh();
11
12
+const file = tmpdir.resolve('test-fs-writestream-open-write.txt');
13
14
+const w = fs.createWriteStream(file);
15
16
+w.on('open', common.mustCall(() => {
17
+ w.write('hello');
18
19
+ process.nextTick(() => {
20
+ w.write('world');
21
+ w.end();
22
+ });
23
+}));
24
25
+w.on('close', common.mustCall(() => {
26
+ strictEqual(fs.readFileSync(file, 'utf8'), 'helloworld');
27
+ fs.unlinkSync(file);
28
0 commit comments