File tree 2 files changed +29
-5
lines changed
2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ function constructNT(stream) {
267
267
} else if ( err ) {
268
268
errorOrDestroy ( stream , err , true ) ;
269
269
} else {
270
- process . nextTick ( emitConstructNT , stream ) ;
270
+ stream . emit ( kConstruct ) ;
271
271
}
272
272
}
273
273
@@ -280,10 +280,6 @@ function constructNT(stream) {
280
280
}
281
281
}
282
282
283
- function emitConstructNT ( stream ) {
284
- stream . emit ( kConstruct ) ;
285
- }
286
-
287
283
function isRequest ( stream ) {
288
284
return stream ?. setHeader && typeof stream . abort === 'function' ;
289
285
}
Original file line number Diff line number Diff line change
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
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments