aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/bindings/bindings.zig5
-rw-r--r--src/bun.js/webcore/response.zig10
-rw-r--r--src/http_client_async.zig2
3 files changed, 11 insertions, 6 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index a97ce3935..c6c71765a 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -1816,6 +1816,11 @@ pub const AbortSignal = extern opaque {
return cppFn("unref", .{this});
}
+ pub fn detach(this: *AbortSignal, ctx: ?*anyopaque) void {
+ _ = this.unref();
+ this.cleanNativeBindings(ctx);
+ }
+
pub fn fromJS(value: JSValue) ?*AbortSignal {
return cppFn("fromJS", .{value});
}
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index d283df5a0..e9e6e2df2 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -659,18 +659,18 @@ pub const Fetch = struct {
this.request_headers.entries.deinit(bun.default_allocator);
this.request_headers.buf.deinit(bun.default_allocator);
this.request_headers = Headers{ .allocator = undefined };
- this.http.?.deinit();
+ this.http.?.clearData();
this.result.deinitMetadata();
this.response_buffer.deinit();
this.request_body.detach();
- if (this.abort_reason != .zero) this.abort_reason.unprotect();
+ if (this.abort_reason != .zero)
+ this.abort_reason.unprotect();
if (this.signal) |signal| {
- signal.cleanNativeBindings(this);
- _ = signal.unref();
this.signal = null;
+ signal.detach(this);
}
}
@@ -720,8 +720,8 @@ pub const Fetch = struct {
pub fn onReject(this: *FetchTasklet) JSValue {
if (this.signal) |signal| {
- _ = signal.unref();
this.signal = null;
+ signal.detach(this);
}
if (!this.abort_reason.isEmptyOrUndefinedOrNull()) {
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index 276186fe5..370037db9 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -1247,7 +1247,7 @@ pub const AsyncHTTP = struct {
}
}
- pub fn deinit(this: *AsyncHTTP) void {
+ pub fn clearData(this: *AsyncHTTP) void {
this.response_headers.deinit(this.allocator);
this.response_headers = .{};
this.request = null;