-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: fix fd is null when calling clearBuffer
PR-URL: #50994 Fixes: #50979 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Raz Luvaton <[email protected]> Reviewed-By: Robert Nagy <[email protected]>
- Loading branch information
1 parent
bd528c7
commit 8750070
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |