aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api')
-rw-r--r--src/bun.js/api/bun.zig23
-rw-r--r--src/bun.js/api/server.zig2
2 files changed, 24 insertions, 1 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig
index 2e6381c74..9932d10cc 100644
--- a/src/bun.js/api/bun.zig
+++ b/src/bun.js/api/bun.zig
@@ -1364,6 +1364,9 @@ pub const Class = NewClass(
.FileSystemRouter = .{
.get = getFileSystemRouter,
},
+ .EventStream = .{
+ .get = getEventStream,
+ },
},
);
@@ -3382,6 +3385,26 @@ pub fn getUnsafe(
return existing.asObjectRef();
}
+extern fn ZigGlobalObject__createEventStream(*JSGlobalObject) JSValue;
+
+pub fn getEventStream(
+ _: void,
+ ctx: js.JSContextRef,
+ _: js.JSValueRef,
+ _: js.JSStringRef,
+ _: js.ExceptionRef,
+) js.JSValueRef {
+ var existing = ctx.ptr().getCachedObject(ZigString.static("EventStream"));
+ if (existing.isEmpty()) {
+ return ctx.ptr().putCachedObject(
+ &ZigString.init("EventStream"),
+ ZigGlobalObject__createEventStream(ctx.ptr()),
+ ).asObjectRef();
+ }
+
+ return existing.asObjectRef();
+}
+
pub const Unsafe = struct {
pub const Class = NewClass(
void,
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 32c4fd25c..1167e6b0f 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -2105,7 +2105,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.setAbortHandler();
streamLog("is in progress, but did not return a Promise. Finalizing request context", .{});
- this.finalize();
+ this.finalizeWithoutDeinit();
stream.value.unprotect();
}