Inching closer

This commit is contained in:
Jarred Sumner
2024-02-09 04:12:41 -08:00
parent e0778944fe
commit 4cde96605a
3 changed files with 9 additions and 2 deletions

View File

@@ -862,7 +862,7 @@ pub const Subprocess = struct {
switch (this.state) {
.pending => {
const stream = JSC.WebCore.ReadableStream.fromPipe(globalObject, &this.reader);
const stream = JSC.WebCore.ReadableStream.fromPipe(globalObject, this, &this.reader);
this.state = .{ .done = &.{} };
return stream;
},

View File

@@ -360,6 +360,7 @@ pub const ReadableStream = struct {
pub fn fromPipe(
globalThis: *JSGlobalObject,
parent: anytype,
buffered_reader: anytype,
) JSC.JSValue {
JSC.markBinding(@src());
@@ -371,6 +372,11 @@ pub const ReadableStream = struct {
});
source.context.reader.from(buffered_reader, &source.context);
if (comptime Environment.isPosix) {
source.context.fd = parent.fd;
parent.fd = bun.invalid_fd;
}
return source.toJS(globalThis);
}

View File

@@ -544,7 +544,8 @@ const PosixBufferedReader = struct {
pub fn registerPoll(this: *PosixBufferedReader) void {
const poll = this.handle.getPoll() orelse brk: {
if (this.handle == .fd and this.pollable) {
break :brk Async.FilePoll.init(this.eventLoop(), this.getFd(), .{}, @This(), this);
this.handle = .{ .poll = Async.FilePoll.init(this.eventLoop(), this.getFd(), .{}, @This(), this) };
break :brk this.handle.poll;
}
return;