Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Tags: openuiai/next.js

Tags

backup-forkhandle-fix

Toggle backup-forkhandle-fix's commit message

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
fix: Implement full ChildProcess compatibility for ForkHandle

This commit fixes jest-worker compatibility issues by implementing
complete ChildProcess API compatibility in the process adapter.

**Root Cause:**
The ForkHandle interface was incompatible with Node.js ChildProcess:
- stdout/stderr were objects instead of real Readable streams
- Event emitter didn't return 'this' for method chaining
- Missing critical ChildProcess properties (connected, killed, etc.)
- Missing methods (disconnect, ref, unref)

This caused jest-worker to hang when trying to pipe streams and
manage worker processes during builds.

**Changes:**

1. Created stream adapters (bun-stream-adapter.ts):
   - BunReadableStream: Wraps Bun stdout/stderr as Node.js Readable
   - BunWritableStream: Wraps Bun stdin as Node.js Writable
   - Full backpressure and async handling

2. Updated ForkHandle interface:
   - Changed stdout/stderr to Readable | null
   - Added stdin: Writable | null
   - Added connected, killed, exitCode, signalCode properties
   - Added disconnect(), ref(), unref() methods
   - Fixed on() to return 'this' for chaining
   - Fixed event signatures to match ChildProcess exactly
   - Updated send() with proper overloads

3. Implemented forkWithBun() with real streams:
   - Uses BunReadableStream/BunWritableStream
   - Proper EventEmitter for correct event handling
   - All ChildProcess methods with correct return types

4. Updated forkWithNode() to match interface

**Result:**
- test-firefox-safari now passes (was failing with all 113 tests)
- Full jest-worker compatibility
- Proper stream piping and consumption

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

Co-Authored-By: Claude <[email protected]>

backup-before-rust-removal

Toggle backup-before-rust-removal's commit message

Unverified

This tag is not signed, but one or more authors requires that any tag attributed to them is signed.
Backup before removing all Rust code