mirror of https://github.com/nodejs/node.git
stream: fix fd is null when calling clearBuffer
PR-URL: https://github.com/nodejs/node/pull/50994 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
parent
3f4ea7ad7f
commit
639c366883
|
@ -733,7 +733,8 @@ function errorBuffer(state) {
|
|||
|
||||
// If there's something in the buffer waiting, then process it.
|
||||
function clearBuffer(stream, state) {
|
||||
if ((state[kState] & (kDestroyed | kBufferProcessing | kCorked | kBuffered)) !== kBuffered) {
|
||||
if ((state[kState] & (kDestroyed | kBufferProcessing | kCorked | kBuffered | kConstructed)) !==
|
||||
(kBuffered | kConstructed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
// Test 'uncork' for WritableStream.
|
||||
// Refs: https://github.com/nodejs/node/issues/50979
|
||||
|
||||
const common = require('../common');
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
const test = require('node:test');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
|
||||
const filepath = tmpdir.resolve('write_stream.txt');
|
||||
tmpdir.refresh();
|
||||
|
||||
const data = 'data';
|
||||
|
||||
test('writable stream uncork', () => {
|
||||
const fileWriteStream = fs.createWriteStream(filepath);
|
||||
|
||||
fileWriteStream.on('finish', common.mustCall(() => {
|
||||
const writtenData = fs.readFileSync(filepath, 'utf8');
|
||||
assert.strictEqual(writtenData, data);
|
||||
}));
|
||||
fileWriteStream.cork();
|
||||
fileWriteStream.write(data, common.mustCall());
|
||||
fileWriteStream.uncork();
|
||||
fileWriteStream.end();
|
||||
});
|
Loading…
Reference in New Issue