Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5112306

Browse filesBrowse files
kylo5abyRafaelGSS
authored andcommitted
stream: fix fd is null when calling clearBuffer
PR-URL: #50994 Fixes: #50979 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Raz Luvaton <rluvaton@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
1 parent 735bad3 commit 5112306
Copy full SHA for 5112306

File tree

Expand file treeCollapse file tree

2 files changed

+30
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/streams/writable.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/writable.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ function errorBuffer(state) {
733733

734734
// If there's something in the buffer waiting, then process it.
735735
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)) {
737738
return;
738739
}
739740

Collapse file
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.