File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -733,7 +733,8 @@ function errorBuffer(state) {
733
733
734
734
// If there's something in the buffer waiting, then process it.
735
735
function clearBuffer ( stream , state ) {
736
- if ( ( state [ kState ] & ( kDestroyed | kBufferProcessing | kCorked | kBuffered ) ) !== kBuffered ) {
736
+ if ( ( state [ kState ] & ( kDestroyed | kBufferProcessing | kCorked | kBuffered | kConstructed ) ) !==
737
+ ( kBuffered | kConstructed ) ) {
737
738
return ;
738
739
}
739
740
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ // Test 'uncork' for WritableStream.
4
+ // Refs: https://github.com/nodejs/node/issues/50979
5
+
6
+ const common = require ( '../common' ) ;
7
+ const fs = require ( 'fs' ) ;
8
+ const assert = require ( 'assert' ) ;
9
+ const test = require ( 'node:test' ) ;
10
+ const tmpdir = require ( '../common/tmpdir' ) ;
11
+
12
+ const filepath = tmpdir . resolve ( 'write_stream.txt' ) ;
13
+ tmpdir . refresh ( ) ;
14
+
15
+ const data = 'data' ;
16
+
17
+ test ( 'writable stream uncork' , ( ) => {
18
+ const fileWriteStream = fs . createWriteStream ( filepath ) ;
19
+
20
+ fileWriteStream . on ( 'finish' , common . mustCall ( ( ) => {
21
+ const writtenData = fs . readFileSync ( filepath , 'utf8' ) ;
22
+ assert . strictEqual ( writtenData , data ) ;
23
+ } ) ) ;
24
+ fileWriteStream . cork ( ) ;
25
+ fileWriteStream . write ( data , common . mustCall ( ) ) ;
26
+ fileWriteStream . uncork ( ) ;
27
+ fileWriteStream . end ( ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments