Skip to content

Commit

Permalink
fix: stuff i forgot to push (#7651)
Browse files Browse the repository at this point in the history
* i forgot

* a
  • Loading branch information
paperclover authored Dec 14, 2023
1 parent 1aaf63e commit beedb28
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/bun.js/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4658,10 +4658,8 @@ void JSC__JSValue__forEachProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* g

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;
Expand Down Expand Up @@ -4754,10 +4752,8 @@ void JSC__JSValue__forEachProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* g

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);
}
Expand Down
18 changes: 17 additions & 1 deletion src/js/builtins/ProcessObjectInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint8Array> | undefined;
var readerRef;
Expand All @@ -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);
Expand All @@ -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");
}
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/js/builtins/ReadableStreamInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down

0 comments on commit beedb28

Please sign in to comment.