Add request body abort logic in RequestContext.finalize

When a request ends with a pending read on the request body stream,
the stream must be aborted to reject the pending read promise.

This mirrors the existing response body abort logic but uses the
request's this_jsvalue to get the proper owner for the Ref system.
This commit is contained in:
Claude Bot
2025-10-05 06:28:50 +00:00
parent 817ebbef9e
commit a6745dffc9

View File

@@ -678,6 +678,19 @@ pub fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool,
any_js_calls = true;
}
// Abort request body stream if still locked (e.g., pending read)
if (this.request_weakref.get()) |request| {
if (request.body.value == .Locked) {
const owner: jsc.WebCore.ReadableStream.Ref.Owner = if (request.this_jsvalue.tryGet()) |js_value|
.{ .Request = js_value }
else
.empty;
if (request.body.value.Locked.readable.abort(owner, globalThis)) {
any_js_calls = true;
}
}
}
if (this.response_ptr) |response| {
if (response.body.value == .Locked) {
if (response.body.value.Locked.readable.abort(.{ .Response = response_jsvalue }, globalThis)) {