aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/webcore/response.zig40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index ff5ad7fcd..b3111e81f 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -612,6 +612,7 @@ pub const Fetch = struct {
const http_response = this.result.response;
var response = allocator.create(Response) catch unreachable;
var internal_blob = this.response_buffer.list.toManaged(this.response_buffer.allocator);
+
this.response_buffer = .{
.allocator = default_allocator,
.list = .{
@@ -4802,27 +4803,26 @@ pub const Body = struct {
}
pub fn useAsAnyBlob(this: *Value) AnyBlob {
- switch (this.*) {
- .Blob => {
- var new_blob = this.Blob;
- std.debug.assert(new_blob.allocator == null); // owned by Body
- this.* = .{ .Used = .{} };
- return .{ .Blob = new_blob };
- },
- .InternalBlob => {
- const data = this.InternalBlob;
- this.* = .{ .Used = .{} };
- return .{ .InternalBlob = data };
- },
- .InlineBlob => {
- const data = this.InlineBlob;
- this.* = .{ .Used = .{} };
- return .{ .InlineBlob = data };
- },
- else => {
- return .{ .Blob = Blob.initEmpty(undefined) };
- },
+ const any_blob: AnyBlob = switch (this.*) {
+ .Blob => .{ .Blob = this.Blob },
+ .InternalBlob => .{ .InternalBlob = this.InternalBlob },
+ .InlineBlob => .{ .InlineBlob = this.InlineBlob },
+ else => .{ .Blob = Blob.initEmpty(undefined) },
+ };
+
+ if (this.* == .Locked) {
+ if (this.Locked.promise) |prom| {
+ prom.unprotect();
+ }
+
+ if (this.Locked.readable) |readable| {
+ readable.done();
+ // TODO: convert the known streams back into blobs
+ }
}
+
+ this.* = .{ .Used = {} };
+ return any_blob;
}
pub fn toErrorInstance(this: *Value, error_instance: JSC.JSValue, global: *JSGlobalObject) void {