stream: avoid writing to writable
A remainder from a previous refactoring. Refs: https://github.com/nodejs/node/pull/31197 PR-URL: https://github.com/nodejs/node/pull/31805 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
5bef2ccf20
commit
85c6fcd1cd
@ -687,7 +687,6 @@ function endWritable(stream, state, cb) {
|
||||
onFinished(stream, state, cb);
|
||||
}
|
||||
state.ended = true;
|
||||
stream.writable = false;
|
||||
}
|
||||
|
||||
function onCorkedFinish(corkReq, state, err) {
|
||||
@ -741,7 +740,7 @@ ObjectDefineProperties(Writable.prototype, {
|
||||
get() {
|
||||
const w = this._writableState;
|
||||
if (!w) return false;
|
||||
if (w.writable !== undefined) return w.writable;
|
||||
if (w.writable !== undefined) return w.writable && !w.ended;
|
||||
return Boolean(!w.destroyed && !w.errored && !w.ending);
|
||||
},
|
||||
set(val) {
|
||||
|
@ -9,17 +9,24 @@ const writable = new stream.Writable();
|
||||
|
||||
writable._write = (chunk, encoding, cb) => {
|
||||
assert.strictEqual(writable._writableState.ended, false);
|
||||
assert.strictEqual(writable._writableState.writable, undefined);
|
||||
assert.strictEqual(writable.writableEnded, false);
|
||||
cb();
|
||||
};
|
||||
|
||||
assert.strictEqual(writable._writableState.ended, false);
|
||||
assert.strictEqual(writable._writableState.writable, undefined);
|
||||
assert.strictEqual(writable.writable, true);
|
||||
assert.strictEqual(writable.writableEnded, false);
|
||||
|
||||
writable.end('testing ended state', common.mustCall(() => {
|
||||
assert.strictEqual(writable._writableState.ended, true);
|
||||
assert.strictEqual(writable._writableState.writable, undefined);
|
||||
assert.strictEqual(writable.writable, false);
|
||||
assert.strictEqual(writable.writableEnded, true);
|
||||
}));
|
||||
|
||||
assert.strictEqual(writable._writableState.ended, true);
|
||||
assert.strictEqual(writable._writableState.writable, undefined);
|
||||
assert.strictEqual(writable.writable, false);
|
||||
assert.strictEqual(writable.writableEnded, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user