aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-08 22:26:58 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-08 22:26:58 -0800
commit0fd7d3a8c3957f2bd4488841271750146f7a674b (patch)
treeb13657306a93ca0f6d30c5ee2f61707d8f926f49
parent8bc459ba998abb4d0819a2c7d522c314bf65a4a4 (diff)
downloadbun-0fd7d3a8c3957f2bd4488841271750146f7a674b.tar.gz
bun-0fd7d3a8c3957f2bd4488841271750146f7a674b.tar.zst
bun-0fd7d3a8c3957f2bd4488841271750146f7a674b.zip
Fix incorrectly reporting URL sizes to GC in some cases
-rw-r--r--src/bun.js/webcore/response.zig12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index d77a5714b..ee62d518b 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -5182,7 +5182,7 @@ pub const Request = struct {
pub fn estimatedSize(this: *Request) callconv(.C) usize {
return this.reported_estimated_size orelse brk: {
- this.reported_estimated_size = @truncate(u63, this.body.estimatedSize() + this.url.len + @sizeOf(Request));
+ this.reported_estimated_size = @truncate(u63, this.body.estimatedSize() + this.sizeOfURL() + @sizeOf(Request));
break :brk this.reported_estimated_size.?;
};
}
@@ -5366,6 +5366,16 @@ pub const Request = struct {
return ZigString.init(this.url).withEncoding().toValueGC(globalObject);
}
+ pub fn sizeOfURL(this: *Request) usize {
+ if (this.url.len > 0)
+ return this.url.len;
+
+ if (this.uws_request) |req| {
+ return this.base_url_string_for_joining.len + req.url().len;
+ }
+
+ return 0;
+ }
pub fn ensureURL(this: *Request) !void {
if (this.url.len > 0) return;