The previous approach of always processing packages broke existing callbacks
that expected to handle package processing themselves. Now we only process
packages automatically when using the default callback, which is what
install_with_manager uses.
- Process packages in default callback case for both extract and git_checkout
- Leave other callbacks (PackageInstaller, Store.Installer) unchanged
- Maintains compatibility with existing code paths
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Git/github packages were being extracted to cache but not installed to node_modules.
The issue was that the runtime extraction callback (onExtractDefault) wasn't
processing the extracted tarballs properly.
- Updated onExtractDefault to call processExtractedTarballPackage for git/github deps
- Simplified extraction handling in runTasks.zig - runtime callbacks now have full control
- Added missing imports needed for compilation
Fixes the issue where packages like 'github:jonschlinkert/is-number' would download
but fail with 'failed to resolve' error.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implemented a runtime callback system to handle package extraction when
there's no installer context. This allows git packages to be installed
to node_modules even when runTasks is called with empty callbacks.
Changes:
- Added ExtractCallback union type and onExtractCallback field to PackageManager
- Updated runTasks to check runtime callbacks before compile-time ones
- Created onExtractDefault callback to process dependency_install_context items
- Updated callers to set up the default callback
Note: There's currently a compilation issue with the Zig compiler terminating
unexpectedly. This needs further investigation - possibly related to type
dependencies or forward references.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
The parser was incorrectly treating git@github.com:user/repo as having
an alias 'git' because 'git' is a valid npm package name. Added checks
to skip git@ prefixed inputs in both branches of the alias detection logic.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
1. Fixed UpdateRequest.zig package name parsing - it was incorrectly handling
package@version format (e.g., bar@0.0.2), setting value to empty string
2. Re-added fix for git packages not being installed to node_modules by
processing remaining dependency_install_context items
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Git packages were being extracted to cache but not copied/linked to node_modules
because dependency_install_context items weren't processed when there was no
onExtract callback. This fix ensures remaining task queue items are processed
after handling regular dependencies.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove "2" dependency that was accidentally added during debugging
- Clean up package.json and bun.lock
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Removed all temporary debug logs added for troubleshooting
- Keep only essential error messages
- All tests still passing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added comprehensive debug logging throughout the JSON parsing pipeline
- Tracks package.json reading and parsing for git dependencies
- Helps diagnose issues with dependency resolution
- All git dependency tests passing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This PR refactors git operations in `bun install` from blocking threadpool calls to async event loop integration for improved performance.
## Changes
- Created new `GitCommandRunner` struct that uses `bun.spawn` for async process handling instead of `std.process.Child.run`
- Replaced blocking git operations with non-blocking event loop integrated operations
- Added support for git fetch when directory already exists (instead of failing with "directory already exists")
- Fixed handling of patches for git dependencies by properly calculating and passing patch hashes
- Added proper cleanup of .git directories and creation of .bun-tag files after checkout
- Fixed SSH URL transformation for patch hash calculation
## Implementation Details
- Git operations now use two-phase approach: `clone --bare` followed by `checkout`
- Properly handles both clone and fetch operations based on directory existence
- Integrates with existing pending task management for event loop coordination
- Maintains compatibility with existing error handling and logging
## Testing
- Existing git dependency tests pass
- Patch support for git dependencies working (in progress)
- No regression in npm package installation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
The original blocking implementation didn't change the working directory
when running git commands. Since we're now using absolute paths for all
git operations (clone target and -C flag for checkout), we don't need
to set a specific cwd.
This matches the original behavior more closely where exec() ran in
the current process's working directory.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
The git clone command was using a relative path (just the folder name)
as the target directory, which caused issues when the working directory
wasn't what git expected. This matches the original blocking implementation
which used the full absolute path.
- Use Path.joinAbsStringZ to build the full path to the target directory
- Pass the absolute path to git clone instead of just the folder name
This fixes "directory already exists" errors in tests.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement patch application for git-based dependencies after checkout.
This ensures that patches specified in patchedDependencies are applied
to git dependencies just like they are for npm registry dependencies.
- Pass patch_name_and_version_hash through to GitCommandRunner
- Create PatchTask when patches are needed after git checkout
- Set apply_patch_task on the result task so patches are applied
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Previously, git commands could fail with ENOENT if git wasn't in PATH
or if the environment wasn't properly propagated. This change uses
bun.which() to find the git executable and passes its full path to
spawn, ensuring git commands work reliably.
- Use bun.which() to locate git in PATH
- Pass full path as argv[0] and argv0 in spawn options
- Handle case where git is not found with proper error
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changed error from spawn failures to error.GitCommandFailed
to avoid confusing ENOENT errors. Tests still fail because
git URLs with fragments need proper handling.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added Windows pipe creation for stdout/stderr
- Fixed error handling to not throw from void functions
- Improved spawn error messages by creating proper failed tasks
- All errors now flow through the task system properly
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Added missing resetOutputFlags function to GitCommandRunner to properly set
output reader flags before starting, matching LifecycleScriptSubprocess behavior.
This ensures correct handling of nonblocking I/O and socket flags.
Also updated test to use smaller repository to avoid timeouts.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This PR refactors git operations in `bun install` from blocking threadpool calls using `std.process.Child` to non-blocking event loop integration using `bun.spawn`.
## Changes
- Created `GitCommandRunner` for async git command execution with event loop integration
- Replaced blocking `fork()` calls with async `bun.spawn`
- Implemented proper two-phase checkout (clone --no-checkout, then checkout)
- Moved post-checkout operations (.git deletion, .bun-tag creation) to appropriate places
- Fixed argv construction to use "git" instead of hardcoded paths
- Added comprehensive tests for git dependencies
## Technical Details
The new implementation:
- Uses tagged pointer unions for process exit handlers
- Properly manages pending task counting for event loop
- Handles both clone and checkout operations asynchronously
- Maintains backward compatibility with existing URL handling
All git operations now integrate properly with Bun's event loop, eliminating blocking operations and improving performance.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
### What does this PR do?
Limit to only 5k test files for initial scan + ignore node_modules for
subdirs.
### How did you verify your code works?
manual
## Summary
This PR fixes a panic that occurs when file operations use buffers
larger than 4GB on Windows.
## The Problem
When calling `fs.readSync()` or `fs.writeSync()` with buffers larger
than 4,294,967,295 bytes (u32::MAX), Bun panics with:
```
panic(main thread): integer cast truncated bits
```
## Root Cause
The Windows APIs `ReadFile()` and `WriteFile()` expect a `DWORD` (u32)
for the buffer length parameter. The code was using `@intCast` to
convert from `usize` to `u32`, which panics when the value exceeds
u32::MAX.
## The Fix
Changed `@intCast` to `@truncate` in four locations:
1. `sys.zig:1839` - ReadFile buffer length parameter
2. `sys.zig:1556` - WriteFile buffer length parameter
3. `bun.zig:230` - platformIOVecCreate length field
4. `bun.zig:240` - platformIOVecConstCreate length field
With these changes, operations with buffers > 4GB will read/write up to
4GB at a time instead of panicking.
## Test Plan
```js
// This previously caused a panic on Windows
const fs = require('fs');
const fd = fs.openSync('test.txt', 'r');
const buffer = Buffer.allocUnsafe(4_294_967_296); // 4GB + 1 byte
fs.readSync(fd, buffer, 0, buffer.length, 0);
```
Fixes https://github.com/oven-sh/bun/issues/21699🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Jarred Sumner <jarred@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
### What does this PR do?
### How did you verify your code works?
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Setting the background color on plaintext diffs makes the plaintext
harder to read. This is particularly true when the input is longer.
This conservatively makes us only add the background color to the diff
when the characters being highlighted are all whitespaces, punctuation
or non-printable.
This branch:
<img width="748" height="388" alt="image"
src="https://github.com/user-attachments/assets/ceaf02ba-bf71-4207-a319-c041c8a887de"
/>
Canary:
<img width="742" height="404" alt="image"
src="https://github.com/user-attachments/assets/cc380f45-5540-48ed-aea1-07f4b0ab291e"
/>
### How did you verify your code works?
Updated test
## Summary
- Adds `Symbol.asyncIterator` to `process.stdout` and `process.stderr`
when they are TTY or pipe/socket streams
- Matches Node.js behavior where these streams are Duplex-like and
support async iteration
- Does not add the iterator when streams are redirected to files
(matching Node.js SyncWriteStream behavior)
## Test plan
- Added test in
`test/regression/issue/test-process-stdout-async-iterator.test.ts`
- Verified the fix works with Claude Code on Linux x64
- Test passes with `bun bd test
test/regression/issue/test-process-stdout-async-iterator.test.ts`
Fixes#21704🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
## Summary
- Fix transpiler bug where comma expressions like `(0, obj.method)()`
were incorrectly optimized to `obj.method()`
- This preserved the `this` binding instead of stripping it as per
JavaScript semantics
- Add comprehensive regression test to prevent future issues
## Root Cause
The comma operator optimization in `src/js_parser.zig:7281` was directly
returning the right operand when the left operand had no side effects,
without checking if the expression was being used as a call target.
## Solution
- Added the same `is_call_target` check that other operators (nullish
coalescing, logical OR/AND) use
- When a comma expression is used as a call target AND the right operand
has a value for `this`, preserve the comma expression to strip the
`this` binding
- Follows existing patterns in the codebase for consistent behavior
## Test Plan
- [x] Reproduce the original bug: `(0, obj.method)()` incorrectly
preserved `this`
- [x] Verify fix: comma expressions now correctly strip `this` binding
in function calls
- [x] All existing transpiler tests continue to pass
- [x] Added regression test covering various comma expression scenarios
- [x] Tested edge cases: nested comma expressions, side effects,
different operand types
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
## Summary
- Updates WebKit from 75f6499 to eb92990 (latest release from
oven-sh/webkit)
- This brings in the latest WebKit improvements and fixes
## Test plan
- [ ] Verify the build completes successfully
- [ ] Run existing test suite to ensure no regressions
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Reduce stack space usage of parseSuffix
### How did you verify your code works?
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
On Linux, AbortSignal.timeout created a file descriptor for each timeout
and did not keep the event loop alive when a timer was active. This is
fixed.
### How did you verify your code works?
Fewer flaky tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude <claude@anthropic.ai>
## Summary
- Replace cmake-based clang-format with dedicated bash script that
directly processes source files
- Optimize CI to only install clang-format-19 instead of entire LLVM
toolchain
- Script enforces specific clang-format version with no fallbacks
## Changes
1. **New bash script** (`scripts/run-clang-format.sh`):
- Directly reads C++ files from `CxxSources.txt`
- Finds all header files in `src/` and `packages/` directories
- Respects existing `.clang-format` configuration files
- Requires specific clang-format version (no fallbacks)
- Defaults to format mode (modifies files in place)
2. **Optimized GitHub Action**:
- Only installs `clang-format-19` package with `--no-install-recommends`
- Avoids installing unnecessary components like manpages
- Uses new bash script instead of cmake targets
3. **Updated package.json scripts**:
- `clang-format`, `clang-format:check`, and `clang-format:diff` now use
the bash script
## Test plan
- [x] Verified script finds and processes all C++ source and header
files
- [x] Tested formatting works correctly by adding formatting issues and
running the script
- [x] Confirmed script respects `.clang-format` configuration files
- [x] Script correctly requires specific clang-format version
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <claude@anthropic.ai>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
- Fixes `$.braces(...)` not working properly on non-ascii inputs
- Switches braces code to use `SmallList` to support more deeply nested
brace expansion
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
### How did you verify your code works?
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
this instance type was reported to be our 1st most expensive per aws
bill
----
before:
x64-linux: 19.5m
arm64-linux: 14m
x64-musl: 16.3m
arm64-musl: 13.3m
x64-windows: 2m
after:
x64-linux: 20.3m
arm64-linux: 15.3m
x64-musl: 16m
arm64-musl: 13.5m
x64-windows: 2.5m