Skip to content

Tags: oven-sh/bun

Tags

bun-v1.3.2

Toggle bun-v1.3.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
ci: run modified tests first (#24463)

Co-authored-by: Meghan Denny <[email protected]>

bun-v1.3.1

Toggle bun-v1.3.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Refactor napi_env to use Ref-counted NapiEnv (#23940)

### What does this PR do?

Replaces raw napi_env pointers with WTF::Ref<NapiEnv> for improved
memory management and safety. Updates related classes, function
signatures, and finalizer handling to use reference counting. Adds
ref/deref methods to NapiEnv and integrates them in Zig and C++ code
paths, ensuring proper lifecycle management for N-API environments.

### How did you verify your code works?

bun-v1.3.0

Toggle bun-v1.3.0's commit message
Update no-validate-leaksan.txt

bun-v1.2.23

Toggle bun-v1.2.23's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat(sql.array) add support to sql.array (#22946)

### What does this PR do?
Fixes #17030 
In this case should work as expected just passing a normal array should
be serialized as JSON/JSONB

Fixes #17798
Insert and update helpers should work as expected here when using
sql.array helper:

```sql
CREATE TABLE user (
    id SERIAL PRIMARY KEY,
    name VARCHAR NOT NULL,
    roles TEXT[]
);
```

```js
const item = { id: 1, name: "test", role: sql.array(['a', 'b'], "TEXT") };
await sql`
  UPDATE user
  SET ${sql(item)}
  WHERE id = 1
`;
```
Fixes #22281
Should work using  sql.array(array, "TEXT")

Fixes #22165
Fixes #22155
Add sql.array(array, typeNameOrTypeID) in Bun.SQL
(#15088)

### How did you verify your code works?
Tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

bun-v1.2.22

Toggle bun-v1.2.22's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix Windows shell crash with && operator and external commands (#22651)

## What does this PR do?

Fixes #22650
Fixes #22615
Fixes #22603
Fixes #22602

Fixes a crash that occurred when running shell commands through `bun
run` (package.json scripts) on Windows that use the `&&` operator
followed by an external command.

### The Problem

The minimal reproduction was:
```bash
bun exec 'echo && node --version'
```

This would crash with: `panic(main thread): attempt to use null value`

### Root Causes

Two issues were causing the crash:

1. **Missing top_level_dir**: When `runPackageScriptForeground` creates
a MiniEventLoop for running package scripts, it wasn't setting the
`top_level_dir` field. This caused a null pointer dereference when the
shell tried to access it.

2. **MovableIfWindowsFd handling**: After PR #21800 introduced
`MovableIfWindowsFd` to handle file descriptor ownership on Windows, the
`IOWriter.fd` could be moved to libuv, leaving it null. When the shell
tried to spawn an external command after a `&&` operator, it would crash
trying to access this null fd.

### The Fix

1. Set `mini.top_level_dir = cwd` after initializing the MiniEventLoop
in `run_command.zig`
2. In `IO.zig`, when the fd has been moved to libuv (is null), use
`.inherit` for stdio instead of trying to pass the null fd

### How did you verify your code works?

- Added a regression test that reproduces the issue
- Verified the test fails without the fix and passes with it
- Tested the minimal reproduction command directly
- The fix correctly allows both commands in the `&&` chain to execute

```bash
# Before fix: crashes
> bun exec 'echo test && node --version'
panic(main thread): attempt to use null value

# After fix: works correctly
> bun exec 'echo test && node --version'
test
v22.4.1
```
<sub>
also probably fixes #22615 and fixes #22603 and fixes #22602
</sub>

---------

Co-authored-by: Zack Radisic <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

bun-v1.2.21

Toggle bun-v1.2.21's commit message
De-flake shell-load.test.ts

bun-v1.2.20

Toggle bun-v1.2.20's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix integer cast truncation panic on Windows for buffers > 4GB (#21738)

## 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 #21699

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

---------

Co-authored-by: Jarred Sumner <[email protected]>
Co-authored-by: Claude <[email protected]>

bun-v1.2.19

Toggle bun-v1.2.19's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Update interactive spacing (#21156)

Co-authored-by: Claude Bot <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: RiskyMH <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <[email protected]>

bun-v1.2.18

Toggle bun-v1.2.18's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fixes #20753 (#20789)

Co-authored-by: Jarred-Sumner <[email protected]>

bun-v1.2.17

Toggle bun-v1.2.17's commit message
Some docs