Skip to content
Prev Previous commit
Next Next commit
stream: fix wrong stream type in adapters.js
  • Loading branch information
CGQAQ authored and aduh95 committed May 11, 2024
commit a93d0c15c702bf398a65ac2cbb0d52f76379078e
14 changes: 7 additions & 7 deletions lib/internal/webstreams/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const {
CountQueuingStrategy,
} = require('internal/webstreams/queuingstrategies');

const { kFresh } = require('internal/webstreams/util');

const {
Writable,
Readable,
Expand Down Expand Up @@ -487,14 +485,16 @@ function newReadableStreamFromStreamReadable(streamReadable, options = kEmptyObj
return controller.error(error);
controller.close();
});

streamReadable.on('data', onData);

return new ReadableStream({
start(c) {
controller = c;
controller[kFresh] = true;
},
// CGQAQ: we know that `Readable.readableHighWaterMark
// size is always in bytes, so we can use `bytes` here
// to make the `ReadableStream` a byte stream.
// Ref: https://streams.spec.whatwg.org/#high-water-mark:~:text=Concretely%2C%20a%20queuing,floating%2Dpoint%20units.
type: "bytes",

start(c) { controller = c; },

pull() { streamReadable.resume(); },

Expand Down
5 changes: 0 additions & 5 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ const {
iteratorNext,
kType,
kState,
kFresh,
} = require('internal/webstreams/util');

const {
Expand Down Expand Up @@ -2352,10 +2351,6 @@ function readableStreamDefaultControllerGetDesiredSize(controller) {
}

function readableStreamDefaultControllerShouldCallPull(controller) {
if (controller[kFresh]) {
controller[kFresh] = false;
return false;
}
const {
stream,
} = controller[kState];
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/webstreams/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const {
validateFunction,
} = require('internal/validators');

const kFresh = Symbol('kFresh');
const kState = Symbol('kState');
const kType = Symbol('kType');

Expand Down Expand Up @@ -296,5 +295,4 @@ module.exports = {
iteratorNext,
kType,
kState,
kFresh,
};