Skip to content

Commit 7053647

Browse files
committed
fixup! stream: readable read one buffer at a time
1 parent 01a9ec9 commit 7053647

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

test/parallel/test-crypto-cipheriv-decipheriv.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ function testCipher1(key, iv) {
3131
// quite small, so there's no harm.
3232
const cStream = crypto.createCipheriv('des-ede3-cbc', key, iv);
3333
cStream.end(plaintext);
34-
ciph = cStream.read();
34+
ciph = cStream.read(cStream.readableLength);
3535

3636
const dStream = crypto.createDecipheriv('des-ede3-cbc', key, iv);
3737
dStream.end(ciph);
38-
txt = dStream.read().toString('utf8');
38+
txt = dStream.read(dStream.readableLength).toString('utf8');
3939

4040
assert.strictEqual(txt, plaintext,
4141
`streaming cipher with key ${key} and iv ${iv}`);

test/parallel/test-stream-readable-infinite-read.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ readable.on('readable', common.mustCall(function() {
2222
return;
2323
}
2424

25-
const data = readable.read();
25+
const data = readable.read(readable.readableLength);
2626
// TODO(mcollina): there is something odd in the highWaterMark logic
2727
// investigate.
2828
if (i === 1) {
29-
assert.strictEqual(data.length, 8192);
29+
assert.strictEqual(data.length, 8192 * 2);
3030
} else {
31-
assert.strictEqual(data.length, 8192);
31+
assert.strictEqual(data.length, 8192 * 2);
3232
}
3333
}, 11));

test/parallel/test-stream-readable-needReadable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const asyncReadable = new Readable({
3232
});
3333

3434
asyncReadable.on('readable', common.mustCall(() => {
35-
if (asyncReadable.read() !== null) {
35+
if (asyncReadable.read(asyncReadable.readableLength) !== null) {
3636
// After each read(), the buffer is empty.
3737
// If the stream doesn't end now,
3838
// then we need to notify the reader on future changes.

test/parallel/test-webstreams-pipeline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const http = require('http');
126126
});
127127

128128
pipeline(r, ws, common.mustSucceed(() => {
129-
assert.deepStrictEqual(values, ['helloworld']);
129+
assert.deepStrictEqual(values, ['hello', 'world']);
130130
}));
131131

132132
r.push('hello');
@@ -181,7 +181,7 @@ const http = require('http');
181181
});
182182

183183
pipeline(rs, t, ws, common.mustSucceed(() => {
184-
assert.deepStrictEqual(values, ['HELLOWORLD']);
184+
assert.deepStrictEqual(values, ['HELLO', 'WORLD']);
185185
}));
186186

187187
c.enqueue('hello');

test/parallel/test-zlib-flush-write-sync-interleaved.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for (const chunk of ['abc', 'def', 'ghi']) {
1919
compress.write(chunk, common.mustCall(() => events.push({ written: chunk })));
2020
compress.flush(Z_PARTIAL_FLUSH, common.mustCall(() => {
2121
events.push('flushed');
22-
const chunk = compress.read();
22+
const chunk = compress.read(compress.readableLength);
2323
if (chunk !== null)
2424
compressedChunks.push(chunk);
2525
}));
@@ -36,7 +36,7 @@ function writeToDecompress() {
3636
const chunk = compressedChunks.shift();
3737
if (chunk === undefined) return decompress.end();
3838
decompress.write(chunk, common.mustCall(() => {
39-
events.push({ read: decompress.read() });
39+
events.push({ read: decompress.read(decompress.readableLength) });
4040
writeToDecompress();
4141
}));
4242
}

0 commit comments

Comments
 (0)