mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 14:22:01 +00:00
Fix Request body stream timeout by upgrading to strong ref
Fixes remaining 41 test timeouts in async-iterator-stream tests for Request bodies. ## Root Cause Request doesn't track `this_jsvalue` (see line 1160 TODO comment in Body.zig). This causes: 1. Request constructor stores stream in GC cache with thisValue 2. Body's `readable.Ref` is set to `.Request` 3. When `getText()`/`json()`/etc is called, owner is always `.empty` (no JSValue) 4. `.get(.empty)` returns null → timeout waiting for stream ## Fix **Request.zig:800-803** - Upgrade Request body Ref to `.strong` in constructor - After setting GC cache, retrieve the stream - Call `.upgrade()` to convert Ref from `.Request` (unusable) to `.strong` - Now `getText()/etc` can retrieve stream via strong ref ## Results async-iterator-stream tests: - ✅ 85/86 tests pass (was 45/86) - 1 test has unrelated chunk length expectation issue All Request body method tests pass: - Request.text() ✅ - Request.json() ✅ - Request.blob() ✅ - Request.arrayBuffer() ✅ - Request.bytes() ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -794,6 +794,13 @@ pub fn constructor(
|
||||
|
||||
if (readable_stream_tee[1] != .zero and result.body.value == .Locked) {
|
||||
js.gc.body.set(thisValue, globalThis, readable_stream_tee[1]);
|
||||
|
||||
// Upgrade to strong ref since Request doesn't track this_jsvalue
|
||||
// Without this, getText()/etc will fail to retrieve the stream (owner is always .empty)
|
||||
const stream = jsc.WebCore.ReadableStream.fromJS(readable_stream_tee[1], globalThis) catch null;
|
||||
if (stream) |s| {
|
||||
result.body.value.Locked.readable.upgrade(&s, globalThis);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user