代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/nodejs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From e0d8242693da7d6c1eb5f2ae75cb224e8bc7397b Mon Sep 17 00:00:00 2001
From: zhenweijin <[email protected]>
Date: Fri, 1 Dec 2023 19:35:05 +0800
Subject: [PATCH] stream: fix fd is null when calling clearBuffer
---
lib/internal/streams/writable.js | 3 ++-
test/parallel/test-file-write-stream5.js | 28 ++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
create mode 100644 test/parallel/test-file-write-stream5.js
diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js
index e55ddc1796cf6c..0dbf56d7a69ca9 100644
--- a/lib/internal/streams/writable.js
+++ b/lib/internal/streams/writable.js
@@ -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;
}
diff --git a/test/parallel/test-file-write-stream5.js b/test/parallel/test-file-write-stream5.js
new file mode 100644
index 00000000000000..cdc8b52eebd48d
--- /dev/null
+++ b/test/parallel/test-file-write-stream5.js
@@ -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();
+});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。