Commit Graph

14611 Commits

Author SHA1 Message Date
Dylan Conway
85607af74f Debug: log PROCESSOR_ARCHITECTURE value
[build images]
2026-02-12 19:38:34 -08:00
Dylan Conway
4d3425702f Fix ARM64 detection: use PROCESSOR_ARCHITECTURE env var
RuntimeInformation.OSArchitecture doesn't exist in PowerShell 5.1
(which Azure Run Command uses), so IsARM64 was always false. This
caused ALL ARM64-specific code paths to be skipped.

[build images]
2026-02-12 19:29:50 -08:00
Dylan Conway
be321246fb Install 7zip manually on ARM64 to avoid Scoop post_install error
Scoop's 7zip ARM64 post_install script has an unfixable Remove-Item
error. Install 7zip directly from 7-zip.org instead.

[build images]
2026-02-12 19:19:12 -08:00
Dylan Conway
0620e2dba3 Fix 7zip ARM64: stringify error output to prevent re-throw
PowerShell 2>&1 | Out-Host passes ErrorRecord objects which re-trigger
ErrorActionPreference=Stop. Convert to strings first.

[build images]
2026-02-12 19:18:09 -08:00
Dylan Conway
e9454881eb [build images] 2026-02-12 19:06:01 -08:00
autofix-ci[bot]
d208189f17 [autofix.ci] apply automated fixes 2026-02-13 03:04:50 +00:00
Dylan Conway
57a7345a39 Fix agent install: use full node path, throw on spawnSafe errors
- machine.mjs: use C:\Scoop\apps\nodejs\current\node.exe instead of
  bare 'node' which isn't in Azure Run Command PATH
- azure.mjs: spawnSafeFn now throws on non-zero exit code so bootstrap
  failures actually stop the build instead of capturing broken images

[build images]
2026-02-12 19:03:01 -08:00
Dylan Conway
4ec90d886b Fix bootstrap: run scoop in-process, isolate only 7zip ARM64
Child process scoop installs break PATH/shims. Only use child process
for 7zip on ARM64 (post_install error). Everything else runs in-process.
nssm falls back to blob storage mirror when nssm.cc is down.

[build images]
2026-02-12 17:56:47 -08:00
Dylan Conway
7a0c9047be Fix bootstrap: VS 3010 exit code, mingw command name
- VS installer exit code 3010 (reboot required) is not a real error
- mingw command is gcc, not mingw
- Use powershell -Command for scoop install isolation

[build images]
2026-02-12 17:44:23 -08:00
Dylan Conway
632b5bb2e8 Make cygwin install non-fatal
Cygwin mirror can be unreachable from Azure VMs. Don't block
the entire bootstrap if cygwin fails to install.

[build images]
2026-02-12 17:17:32 -08:00
Dylan Conway
0cefa2c753 Run scoop install in child process to isolate errors
Scoop's 7zip post_install throws a terminating error on ARM64 that
propagates regardless of ErrorActionPreference. Running scoop in a
child PowerShell process isolates the error completely.

[build images]
2026-02-12 17:08:23 -08:00
Dylan Conway
24e3598d2b Also pre-delete 7zr.exe before 7zip install
[build images]
2026-02-12 17:08:09 -08:00
Dylan Conway
4f0546f919 Fix 7zip ARM64: install before git + suppress scoop errors
7zip is a Scoop dependency of git. On ARM64 SYSTEM, 7zip's post_install
fails trying to delete 7zr.exe from TEMP. Fix by:
1. Moving Install-7zip before Install-Git so it's already installed
2. Using SilentlyContinue in Install-Scoop-Package then verifying

[build images]
2026-02-12 17:04:50 -08:00
Dylan Conway
928fc7888b Fix 7zip: use SilentlyContinue for scoop install
The Remove-Item error in Scoop's 7zip post_install is a terminating
error that propagates through try/catch. Use SilentlyContinue to
suppress it, then verify 7z is actually installed.

[build images]
2026-02-12 16:54:38 -08:00
Dylan Conway
1980c8e12a Fix 7zip install: use try/catch for post_install cleanup error
[build images]
2026-02-12 16:43:56 -08:00
Dylan Conway
d55d35acc7 [build images] 2026-02-12 16:36:24 -08:00
Dylan Conway
d75f4e1135 [build images] 2026-02-12 16:33:32 -08:00
Dylan Conway
c999c5a24d [build images] 2026-02-12 16:30:41 -08:00
Dylan Conway
684d577d14 Update default gallery to bunCIGallery2 (eastus2) 2026-02-12 16:30:20 -08:00
Dylan Conway
9546b6d395 Switch Azure to eastus2 (100 core quota) and restore D8 VMs
[build images]
2026-02-12 16:27:13 -08:00
Dylan Conway
fed0567860 [build images] 2026-02-12 16:12:57 -08:00
Dylan Conway
4056e5927f Fix bootstrap failures on Azure VMs
- 7zip: tolerate post_install cleanup error (access denied on TEMP)
- Rust: set CARGO_HOME/RUSTUP_HOME before rustup-init to avoid
  SYSTEM profile path issue (Move-Item failure)
- nssm: fall back to blob storage mirror when nssm.cc returns 503
2026-02-12 16:12:20 -08:00
Dylan Conway
3313ff96b8 [build images] 2026-02-12 15:53:02 -08:00
Dylan Conway
a82cf004dd [build images] 2026-02-12 14:06:47 -08:00
autofix-ci[bot]
48c0d5d3b5 [autofix.ci] apply automated fixes 2026-02-12 22:00:58 +00:00
Dylan Conway
346d662547 [build images] 2026-02-12 13:58:13 -08:00
Dylan Conway
4846534f00 [build images] 2026-02-12 13:25:49 -08:00
Dylan Conway
ecd6d8ea68 [build images] 2026-02-12 11:38:12 -08:00
Dylan Conway
58e5724a9b [build images] 2026-02-11 21:59:51 -08:00
Dylan Conway
4aafb2a29f [build images] 2026-02-11 21:56:09 -08:00
Dylan Conway
76c2b12821 [build images] 2026-02-11 19:45:06 -08:00
Dylan Conway
35c00e250d [build images] 2026-02-11 19:27:52 -08:00
Dylan Conway
899f08a58d update 2026-02-11 12:50:06 -08:00
Dylan Conway
34f4ecfcc8 Merge remote-tracking branch 'origin/main' into dylan/native-windows-aarch64-build 2026-02-11 12:46:58 -08:00
Dylan Conway
83d1c92cda optional deps 2026-02-11 12:46:41 -08:00
Dylan Conway
50e478dcdc fix(crypto): correct method and constructor names mangled by number renamer (#26876)
## Problem

The bundler's number renamer was mangling `.name` properties on crypto
class prototype methods and constructors:

- `hash.update.name` → `"update2"` instead of `"update"`
- `verify.verify.name` → `"verify2"` instead of `"verify"`
- `cipher.update.name` → `"update3"` instead of `"update"`
- `crypto.Hash.name` → `"Hash2"` instead of `"Hash"`

### Root causes

1. **Named function expressions on prototypes** collided with other
bindings after scope flattening (e.g. `Verify.prototype.verify =
function verify(...)` collided with the imported `verify`)
2. **Block-scoped constructor declarations** (`Hash`, `Hmac`) got
renamed when the bundler hoisted them out of block scope
3. **Shared function declarations** in the Cipher/Decipher block all got
numeric suffixes (`update3`, `final2`, `setAutoPadding2`, etc.)

## Fix

- Use `Object.assign` with object literals for prototype methods —
object literal property keys correctly infer `.name` and aren't subject
to the renamer
- Remove unnecessary block scopes around `Hash` and `Hmac` constructors
so they stay at module level and don't get renamed
- Inline `Cipheriv` methods and copy references to `Decipheriv`

## Tests

Added comprehensive `.name` tests for all crypto classes: Hash, Hmac,
Sign, Verify, Cipheriv, Decipheriv, DiffieHellman, ECDH, plus factory
functions and constructor names.
2026-02-10 23:06:22 -08:00
robobun
e8f73601c0 fix(compile): use remaining buffer in standalone POSIX write loop (#26882)
## What does this PR do?

Fixes the write loop in `StandaloneModuleGraph.inject()` for POSIX
targets (the `else` branch handling ELF/Linux standalone binaries) to
pass `remain` instead of `bytes` to `Syscall.write()`.

## Problem

The write loop that appends the bundled module graph to the end of the
executable uses a standard partial-write retry pattern, but passes the
full `bytes` buffer on every iteration instead of the remaining portion:

```zig
var remain = bytes;
while (remain.len > 0) {
    switch (Syscall.write(cloned_executable_fd, bytes)) {   // bug: should be 'remain'
        .result => |written| remain = remain[written..],
        ...
    }
}
```

If a partial write occurs, the next iteration re-writes from the start
of the buffer instead of continuing where it left off, corrupting the
output binary. The analogous read loop elsewhere in the same file
already correctly uses `remain`.

## Fix

One-character change: `bytes` → `remain` in the `Syscall.write()` call.

## How did you verify your code works?

- `bun bd` compiles successfully
- `bun bd test test/bundler/bun-build-compile.test.ts` — 4/4 pass

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

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Alistair Smith <alistair@anthropic.com>
2026-02-10 23:04:46 -08:00
robobun
ba6e84fecd fix(compile): seek to start of file before EXDEV cross-device copy (#26883)
## What does this PR do?

Fixes `bun build --compile` producing an all-zeros binary when the
output directory is on a different filesystem than the temp directory.
This is common in Docker containers, Gitea runners, and other
environments using overlayfs.

## Problem

When `inject()` finishes writing the modified executable to the temp
file, the file descriptor's offset is at EOF. If the subsequent
`renameat()` to the output path fails with `EXDEV` (cross-device — the
temp file and output dir are on different filesystems), the code falls
back to `copyFileZSlowWithHandle()`, which:

1. Calls `fallocate()` to pre-allocate the output file to the correct
size (filled with zeros)
2. Calls `bun.copyFile(in_handle, out_handle)` — but `in_handle`'s
offset is at EOF
3. `copy_file_range` / `sendfile` / `read` all use the current file
offset (EOF), read 0 bytes, and return immediately
4. Result: output file is the correct size but entirely zeros

This explains user reports of `bun build --compile
--target=bun-darwin-arm64` producing invalid binaries that `file`
identifies as "data" rather than a Mach-O executable.

## Fix

Seek the input fd to offset 0 in `copyFileZSlowWithHandle` before
calling `bun.copyFile`.

## How did you verify your code works?

- `bun bd` compiles successfully
- `bun bd test test/bundler/bun-build-compile.test.ts` — 6/6 pass
- Added tests that verify compiled binaries have valid executable
headers and produce correct output
- Manually verified cross-compilation: `bun build --compile
--target=bun-darwin-arm64` produces a valid Mach-O binary

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

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-10 22:32:31 -08:00
SUZUKI Sosuke
e29e830a25 perf(path): use pre-built Structure for path.parse() result objects (#26865)
## Summary

Optimize `path.parse()` by caching a pre-built JSC Structure for the
result object. Instead of creating a new empty object and performing 5
`putDirect` calls (each triggering a Structure transition), we now use
`constructEmptyObject` with the cached Structure and write values
directly via `putDirectOffset`.

## What changed

- **`ZigGlobalObject.h/cpp`**: Added `m_pathParsedObjectStructure` as a
`LazyPropertyOfGlobalObject<Structure>` with fixed property offsets for
`{root, dir, base, ext, name}`.
- **`Path.cpp`**: Added `PathParsedObject__create` extern "C" factory
function that constructs the object using the pre-built Structure and
`putDirectOffset`.
- **`path.zig`**: Replaced `toJSObject()` implementation to call the C++
factory function instead of `createEmptyObject` + 5x `.put()`.
- **`bench/snippets/path-parse.mjs`**: Added benchmark for
`path.parse()`.

This follows the same pattern used by `JSSocketAddressDTO` and
`m_jsonlParseResultStructure`.

## Benchmark results (Apple M4 Max)

| Benchmark | Before (1.3.9) | After | Speedup |
|---|---|---|---|
| `posix.parse("/home/user/dir/file.txt")` | 266.71 ns | 119.62 ns |
**2.23x** |
| `posix.parse("/home/user/dir/")` | 239.10 ns | 91.46 ns | **2.61x** |
| `posix.parse("file.txt")` | 232.55 ns | 89.20 ns | **2.61x** |
| `posix.parse("/root")` | 246.75 ns | 92.68 ns | **2.66x** |
| `posix.parse("")` | 152.19 ns | 20.72 ns | **7.34x** |
| `win32.parse("/home/user/dir/file.txt")` | 260.08 ns | 118.12 ns |
**2.20x** |
| `win32.parse("/home/user/dir/")` | 234.35 ns | 93.47 ns | **2.51x** |
| `win32.parse("file.txt")` | 224.19 ns | 80.56 ns | **2.78x** |
| `win32.parse("/root")` | 241.20 ns | 88.23 ns | **2.73x** |
| `win32.parse("")` | 160.39 ns | 24.20 ns | **6.63x** |

**~2.2x–2.8x faster** for typical paths, **~7x faster** for empty
strings.

## GC Safety

- `LazyPropertyOfGlobalObject<Structure>` is automatically visited via
`FOR_EACH_GLOBALOBJECT_GC_MEMBER`.
- JSValues created by `createUTF8ForJS` are protected by JSC's
conservative stack scanning during the factory function call.

## Test

All 116 existing path tests pass (`bun bd test test/js/node/path/`).

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-02-10 22:32:08 -08:00
Dylan Conway
00589c3215 Merge branch 'main' into dylan/native-windows-aarch64-build 2026-02-10 17:42:04 -08:00
Dylan Conway
ef5f9adb2c update tests 2026-02-10 17:31:33 -08:00
robobun
4c205486d6 fix(test): update valkey test snapshots for Redis 8 error message format (#26878)
## Summary
- Update inline error snapshots in valkey reliability tests to match
Redis 8's changed error message format
- Redis 8 (`redis:8-alpine` in our test Docker container) no longer
appends `, with args beginning with: ` when an unknown command has no
arguments

## Root cause
Redis commit
[`25f780b6`](25f780b662)
([PR #14690](https://github.com/redis/redis/pull/14690)) changed
`commandCheckExistence()` in `src/server.c` to only append `, with args
beginning with: ` when there are actual arguments (`c->argc >= 2`).
Previously it was always appended, producing a dangling `, with args
beginning with: ` even with zero arguments.

## Changes
- `test/js/valkey/reliability/protocol-handling.test.ts`: Updated
`SYNTAX-ERROR` snapshot (no args case)
- `test/js/valkey/reliability/error-handling.test.ts`: Updated
`undefined` and `123` snapshots (no args cases)

## Test plan
- [ ] Verify `protocol-handling.test.ts` passes in CI (was failing on
every attempt as shown in #26869 / build #36831)
- [ ] Verify `error-handling.test.ts` passes in CI

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

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-10 16:30:55 -08:00
Alistair Smith
099b5e430c feat(test): add --retry flag and emit separate testcase entries for retries in JUnit XML (#26866)
#### (Copies commits from #26447)

## Summary
- Add a global `--retry <N>` flag to `bun test` that sets a default
retry count for all tests (overridable by per-test `{ retry: N }`). Also
configurable via `[test] retry = N` in bunfig.toml.
- When a test passes after one or more retries, the JUnit XML reporter
emits a separate `<testcase>` entry for each failed attempt (with
`<failure>`), followed by the final passing `<testcase>`. This gives
flaky test detection tools per-attempt timing and result data using
standard JUnit XML that all CI systems can parse.

## Test plan
- `bun bd test test/js/junit-reporter/junit.test.js` — verifies separate
`<testcase>` entries appear in JUnit XML for tests that pass after retry
- `bun bd test test/cli/test/retry-flag.test.ts` — verifies the
`--retry` CLI flag applies a default retry count to all tests

## Changelog
<!-- CHANGELOG:START -->
- Added `--retry <N>` flag to `bun test` to set a default retry count
for all tests
- Added `[test] retry` option to bunfig.toml
- JUnit XML reporter now emits separate `<testcase>` entries for each
retry attempt, providing CI visibility into flaky tests
<!-- CHANGELOG:END -->

---------

Co-authored-by: Chris Lloyd <chrislloyd@anthropic.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 10:58:21 -08:00
Przemysław Rekucki
746771d495 fix(bake): queue pending HMR scripts for reuse (#19736) (#23995)
## Summary

Fixes "Unknown HMR script" error during rapid consecutive edits in HMR

## Test plan
- [x] Basic consecutive HMR edits work correctly

---------

Co-authored-by: Alistair Smith <alistair@anthropic.com>
2026-02-10 01:53:07 -08:00
Dylan Conway
60e21aea92 2026-02-09 23:27:28 -08:00
Dylan Conway
1de01eefd4 2026-02-09 23:23:08 -08:00
Dylan Conway
6c0a4b3fa1 2026-02-09 23:00:14 -08:00
Dylan Conway
6897c110c0 2026-02-09 22:51:07 -08:00
Dylan Conway
e84f625569 2026-02-09 22:42:10 -08:00
Dylan Conway
ae50b05b50 2026-02-09 22:40:52 -08:00