From e8fd3a37adef5213d0c0163d0097bc4be4aa77d5 Mon Sep 17 00:00:00 2001 From: snwy Date: Fri, 1 Nov 2024 21:15:51 -0700 Subject: [PATCH] let it roll, let it crash down low --- src/js/internal/primordials.js | 3 +-- src/js/internal/streams/end-of-stream.js | 4 ++-- src/js/internal/streams/pipeline.js | 2 +- src/js/internal/streams/readable.js | 8 ++++++-- src/js/internal/webstreams/adapters.js | 1 + 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/js/internal/primordials.js b/src/js/internal/primordials.js index bc62a7cb5b..f0bfbcc67b 100644 --- a/src/js/internal/primordials.js +++ b/src/js/internal/primordials.js @@ -29,8 +29,7 @@ function getGetter(cls, getter) { } function uncurryThis(func) { - // Intrinsics do not have `call` as a valid identifier, so this cannot be `Function.prototype.call.bind`. - return FunctionPrototypeCall.bind(func); + return (...args) => func.$call(...args); } const copyProps = (src, dest) => { diff --git a/src/js/internal/streams/end-of-stream.js b/src/js/internal/streams/end-of-stream.js index e8efc7442b..93832f9b1a 100644 --- a/src/js/internal/streams/end-of-stream.js +++ b/src/js/internal/streams/end-of-stream.js @@ -127,10 +127,10 @@ function eos(stream, options, callback) { } if (readable && !readableFinished && isReadableNodeStream(stream, true)) { - if (!isReadableFinished(stream, false)) return callback.$call(stream, $ERR_STREAM_PREMATURE_CLOSE()); + if (!isReadableFinished(stream, false)) return callback.$call(stream, $ERR_STREAM_PREMATURE_CLOSE("readable")); } if (writable && !writableFinished) { - if (!isWritableFinished(stream, false)) return callback.$call(stream, $ERR_STREAM_PREMATURE_CLOSE()); + if (!isWritableFinished(stream, false)) return callback.$call(stream, $ERR_STREAM_PREMATURE_CLOSE("writable")); } callback.$call(stream); diff --git a/src/js/internal/streams/pipeline.js b/src/js/internal/streams/pipeline.js index d4fb8757d9..84583deab4 100644 --- a/src/js/internal/streams/pipeline.js +++ b/src/js/internal/streams/pipeline.js @@ -219,7 +219,6 @@ function pipelineImpl(streams, callback, opts) { } function finishImpl(err, final) { - console.trace("finishImpl", err, final); if (err && (!error || error.code === "ERR_STREAM_PREMATURE_CLOSE")) { error = err; } @@ -296,6 +295,7 @@ function pipelineImpl(streams, callback, opts) { if (isTransformStream(ret)) { ret = makeAsyncIterable(ret?.readable); } else { + // AAAA FUCK AAAAAAA ret = makeAsyncIterable(ret); } ret = stream(ret, { signal }); diff --git a/src/js/internal/streams/readable.js b/src/js/internal/streams/readable.js index 0319bb23ac..944afc8c14 100644 --- a/src/js/internal/streams/readable.js +++ b/src/js/internal/streams/readable.js @@ -568,8 +568,12 @@ Readable.prototype.setEncoding = function (enc) { const decoder = new StringDecoder(enc); state.decoder = decoder; - // If setEncoding(null), decoder.encoding equals utf8. - state.encoding = state.decoder.encoding; + + if (enc == null) { + state.encoding = "utf8"; + } else { + state.encoding = state.decoder.encoding; + } // Iterate over current buffer to convert already stored Buffers: let content = ""; diff --git a/src/js/internal/webstreams/adapters.js b/src/js/internal/webstreams/adapters.js index 6512c47f8b..ef4076c733 100644 --- a/src/js/internal/webstreams/adapters.js +++ b/src/js/internal/webstreams/adapters.js @@ -30,6 +30,7 @@ const Duplex = require("../streams/duplex"); const kEmptyObject = Object.freeze({ __proto__: null }); +const { destroy } = require("../streams/destroy"); function handleKnownInternalErrors(cause) { switch (true) {