aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-22 20:16:08 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-22 20:16:08 -0800
commit16ea1753b4ab0cdee67c40a4b88572acb45cd35c (patch)
tree4fe5bda7d1da8bf53070eec695d3a9c4f87c33a4 /src
parent24d624b176df241936d4ec82b2d6f93861de6229 (diff)
downloadbun-16ea1753b4ab0cdee67c40a4b88572acb45cd35c.tar.gz
bun-16ea1753b4ab0cdee67c40a4b88572acb45cd35c.tar.zst
bun-16ea1753b4ab0cdee67c40a4b88572acb45cd35c.zip
Fix missing ref() in lazily created signal
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/webcore/request.zig23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig
index b2dfe829e..fc5bff2b5 100644
--- a/src/bun.js/webcore/request.zig
+++ b/src/bun.js/webcore/request.zig
@@ -221,18 +221,18 @@ pub const Request = struct {
pub fn getSignal(this: *Request, globalThis: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
// Already have an C++ instance
- if(this.signal) |signal| {
+ if (this.signal) |signal| {
return signal.toJS(globalThis);
} else {
//Lazy create default signal
const js_signal = AbortSignal.create(globalThis);
js_signal.ensureStillAlive();
if (AbortSignal.fromJS(js_signal)) |signal| {
- this.signal = signal;
+ this.signal = signal.ref();
}
return js_signal;
}
- }
+ }
pub fn getMethod(
this: *Request,
@@ -271,9 +271,9 @@ pub const Request = struct {
}
this.body.deinit();
- if(this.signal) |signal| {
- _ = signal.unref();
- this.signal = null;
+ if (this.signal) |signal| {
+ _ = signal.unref();
+ this.signal = null;
}
bun.default_allocator.destroy(this);
@@ -440,10 +440,10 @@ pub const Request = struct {
if (AbortSignal.fromJS(signal_)) |signal| {
//Keep it alive
signal_.ensureStillAlive();
- request.signal = signal;
- _ = signal.ref();
-
+ request.signal = signal.ref();
} else {
+ globalThis.throw("Failed to construct 'Request': member signal is not of type AbortSignal.", .{});
+
if (request.headers) |head| {
head.deref();
}
@@ -544,9 +544,8 @@ pub const Request = struct {
this.headers = req.headers.?.cloneThis(globalThis).?;
}
- if(this.signal) |signal| {
- _ = signal.ref();
- req.signal = signal;
+ if (this.signal) |signal| {
+ req.signal = signal.ref();
}
}