aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/bindings.zig5
-rw-r--r--src/bun.js/webcore/response.zig10
2 files changed, 10 insertions, 5 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()) {