Commit Graph

21 Commits

Author SHA1 Message Date
Claude Bot
2c847c156c Remove debug logging from Body and ReadableStream
All 86 async-iterator-stream tests now passing!
2025-10-05 01:40:07 +00:00
Claude Bot
ff0fb1ee77 Fix async generator Response body hang by upgrading Ref to strong
Fixes hang in async-iterator-stream tests for Response bodies with async generators.

## Root Cause

When `new Response(async generator)` is created:
1. Response constructor stores stream in GC cache (weak ref)
2. Body's `readable.Ref` is set to `.Response` (relies on GC cache)
3. RequestContext receives Response and protects the JSValue
4. BUT: Between Response creation and RequestContext using it, GC could collect the stream
5. When RequestContext calls `.get()`, it returns `null` → hangs waiting for stream

## Fix

**RequestContext.zig:1833-1836** - Upgrade Ref to `.strong` before using
- Call `.get()` to retrieve the stream
- Call `.upgrade()` to convert Ref to `.strong` (prevents GC)
- Subsequent `.get()` calls succeed with strong reference

**ReadableStream.zig:124** - Fix upgrade() bug (pre-existing)
- Changed `current.value` to `current.*`
- `Strong.init()` expects full ReadableStream struct, not just JSValue

## Results

async-iterator-stream tests:
-  45 tests pass (was 0)
- ⚠️ 41 Request body tests still timeout (different issue)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 23:26:18 +00:00
autofix-ci[bot]
24c7dbf242 [autofix.ci] apply automated fixes 2025-10-04 22:11:04 +00:00
Claude Bot
5f1c7453cb Fix ReadableStream.Ref to use strong references when owner has no JSValue
The issue was that when Request.getBody() or Response.getBody() is called
without a valid JSValue owner (e.g., owner.Request == .zero), the code was
trying to store streams in the GC cache, which failed silently, leading to
null reference panics and hanging tests.

Changes:

1. **Body.zig:443-456** - When converting blob to stream in toReadableStream()
   - Check if owner has valid JSValue
   - Use .strong ref if JSValue is .zero or owner is .empty
   - Only set GC cache if owner has valid JSValue

2. **Body.zig:502-519** - When creating stream from drain in toReadableStream()
   - Same logic: use .strong if no valid owner JSValue
   - Fixes panics from unwrapping null on lines 504/507

3. **ReadableStream.zig:127-142** - Fix Ref.init() for empty/strong owners
   - Return .empty instead of trying to create .strong without a stream
   - Caller should use .set() to populate

This fixes the body-stream.test.ts hang. The tests now pass but the full
suite (4,883 tests) takes a very long time (~3s/test for large streaming
tests = ~4 hours total). Individual test subsets all pass correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 22:07:11 +00:00
Claude Bot
699d8474df Fix body-stream test hang and ReadableStream.Ref ownership issues
This commit fixes several issues with the new ReadableStream.Ref system
that caused body-stream tests to hang:

1. **Body.zig:1020** - Fixed owner mismatch when setting stream after draining
   - Was using `.strong` owner when should use actual owner (Request/Response)
   - This caused Ref.get() to fail since Ref type didn't match owner type

2. **Body.zig:964,1026** - Set proper Ref type for cloned bodies
   - When tee() returns streams via array, cloned body gets proper Ref type
   - Ensures cloned body can access its stream via GC cache

3. **Request.zig:819** - Fixed stream assignment in doClone
   - Stream[0] should go to original request, not cloned request

4. **ReadableStream.zig:108** - Always update original Ref after tee()
   - Original body's Ref must point to its tee'd stream

5. **body-stream.test.ts** - Fixed test discovery hang
   - Changed from eager to lazy array creation using factory function
   - Prevents creating hundreds of 2MB arrays during test discovery
   - Arrays now created on-demand when each test runs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 14:46:01 +00:00
Jarred Sumner
a4c4bcd4be a 2025-10-02 21:56:29 -07:00
Jarred Sumner
a9c930d797 finish 2025-10-02 15:34:15 -07:00
Jarred Sumner
d9a7dab269 a 2025-09-30 22:33:22 -07:00
Jarred Sumner
da9b27f849 initial 2025-09-30 21:50:41 -07:00
Meghan Denny
5b972fa2b4 zig: ban not using .true and .false for js boolean literals (#21329)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.com>
2025-08-20 16:16:11 -07:00
taylor.fish
07cd45deae Refactor Zig imports and file structure (part 1) (#21270)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-22 17:51:38 -07:00
pfg
83760fc446 Sort imports in all files (#21119)
Co-authored-by: taylor.fish <contact@taylor.fish>
2025-07-21 13:26:47 -07:00
Meghan Denny
875604a42b safety: a lot more exception checker progress (#20956) 2025-07-16 00:11:19 -07:00
Meghan Denny
6c5b863530 safety: a lot more exception checker progress (#20817) 2025-07-10 15:34:51 -07:00
Meghan Denny
f9712ce309 make node:buffer,zlib,stream,fs exception checker clear (#20494) 2025-06-25 18:36:08 -07:00
Meghan Denny
6b4662ff55 zig: .jsUndefined -> .js_undefined (#20377)
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com>
2025-06-13 16:14:57 -07:00
Meghan Denny
dedd433cbf zig: prefer .jsUndefined() over .undefined for JSValue (#20332) 2025-06-12 13:18:46 -07:00
Jarred Sumner
390798c172 Fix memory leak in Bun.spawn (#20095)
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2025-05-31 20:06:22 -07:00
Dylan Conway
a0819e9d02 fix more node:timers tests (#19432)
Co-authored-by: 190n <ben@bun.sh>
2025-05-02 20:50:02 -07:00
chloe caruso
80aff24951 fix: require.extensions uses Strong instead of being clever (#19231) 2025-04-23 17:52:41 -07:00
chloe caruso
3349c995b5 no usingnamespace, organize jsc namespace, enable -fincremental (#19122)
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2025-04-22 16:34:15 -07:00