mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
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:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user