GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: fix fd is null when calling clearBuffer · nodejs/node@5112306

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/streams
    • writable.js
  • test/parallel
    • test-file-write-stream5.js
Expand file treeCollapse file tree
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

‎test/parallel/test-file-write-stream5.js‎

Copy file name to clipboard
+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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.