From beedb28e38170a933c8a4e7b741553d39e9d2bcf Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 13 Dec 2023 22:41:37 -0800 Subject: [PATCH] fix: stuff i forgot to push (#7651) * i forgot * a --- src/bun.js/bindings/bindings.cpp | 8 ++------ src/js/builtins/ProcessObjectInternals.ts | 18 +++++++++++++++++- src/js/builtins/ReadableStreamInternals.ts | 1 - 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 1a0f32ffa1..1cb06c5f8b 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -4658,10 +4658,8 @@ restart: bool isPrivate = prop->isSymbol() && Identifier::fromUid(vm, prop).isPrivateName(); -#if !BUN_DEBUG - if (isPrivate) + if (isPrivate && !JSC::Options::showPrivateScriptsInStackTraces()) return true; -#endif iter(globalObject, arg2, &key, JSC::JSValue::encode(propertyValue), prop->isSymbol(), isPrivate); return true; @@ -4754,10 +4752,8 @@ restart: bool isPrivate = property.isPrivateName(); -#if !BUN_DEBUG - if (isPrivate) + if (isPrivate && !JSC::Options::showPrivateScriptsInStackTraces()) continue; -#endif iter(globalObject, arg2, &key, JSC::JSValue::encode(propertyValue), property.isSymbol(), isPrivate); } diff --git a/src/js/builtins/ProcessObjectInternals.ts b/src/js/builtins/ProcessObjectInternals.ts index 3759a2d261..f9736608dd 100644 --- a/src/js/builtins/ProcessObjectInternals.ts +++ b/src/js/builtins/ProcessObjectInternals.ts @@ -70,6 +70,7 @@ export function getStdinStream(fd) { // Ideally we could use this: // return require("node:stream")[Symbol.for("::bunternal::")]._ReadableFromWeb(Bun.stdin.stream()); // but we need to extend TTY/FS ReadStream + const native = Bun.stdin.stream(); var reader: ReadableStreamDefaultReader | undefined; var readerRef; @@ -78,7 +79,7 @@ export function getStdinStream(fd) { function ref() { $debug("ref();", reader ? "already has reader" : "getting reader"); - reader ??= Bun.stdin.stream().getReader(); + reader ??= native.getReader(); // TODO: remove this. likely we are dereferencing the stream // when there is still more data to be read. readerRef ??= setInterval(() => {}, 1 << 30); @@ -104,6 +105,21 @@ export function getStdinStream(fd) { // Releasing the lock is not possible as there are active reads // we will instead pretend we are unref'd, and release the lock once the reads are finished. shouldUnref = true; + + // unref the native part of the stream + try { + $getByIdDirectPrivate( + $getByIdDirectPrivate(native, "readableStreamController"), + "underlyingByteSource", + ).$resume(false); + } catch (e) { + if (IS_BUN_DEVELOPMENT) { + // we assume this isn't possible, but because we aren't sure + // we will ignore if error during release, but make a big deal in debug + console.error(e); + $assert(!"reachable"); + } + } } } } diff --git a/src/js/builtins/ReadableStreamInternals.ts b/src/js/builtins/ReadableStreamInternals.ts index 75c0f61193..6efaf3cf1b 100644 --- a/src/js/builtins/ReadableStreamInternals.ts +++ b/src/js/builtins/ReadableStreamInternals.ts @@ -1490,7 +1490,6 @@ export function readableStreamReaderGenericRelease(reader) { var stream = $getByIdDirectPrivate(reader, "ownerReadableStream"); if ($getByIdDirectPrivate(stream, "bunNativeType") != 0) { - $debug(stream); $getByIdDirectPrivate($getByIdDirectPrivate(stream, "readableStreamController"), "underlyingByteSource").$resume( false, );