Alistair Smith
e63608fced
Fix: Make SQL connection string parsing more sensible ( #22260 )
...
This PR makes connection string parsing more sensible in Bun.SQL,
without breaking the default fallback of postgres
Added some tests checking for connection string precedence
---------
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>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com >
2025-09-08 20:59:24 -07:00
Ciro Spaciari
14832c5547
fix(CI) update cert in harness ( #22440 )
...
### What does this PR do?
update harness.ts
### How did you verify your code works?
CI
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-05 20:42:25 -07:00
Ciro Spaciari
b79bbfe289
fix(Bun.SQL) fix SSLRequest ( #22378 )
...
### What does this PR do?
Fixes https://github.com/oven-sh/bun/issues/22312
Fixes https://github.com/oven-sh/bun/issues/22313
The correct flow for TLS handshaking is:
Server sending
[Protocol::Handshake](https://dev.mysql.com/doc/dev/mysql-server/8.4.5/page_protocol_connection_phase_packets_protocol_handshake.html )
Client replying with
[Protocol::SSLRequest:](https://dev.mysql.com/doc/dev/mysql-server/8.4.5/page_protocol_connection_phase_packets_protocol_ssl_request.html )
The usual SSL exchange leading to establishing SSL connection
Client sends
[Protocol::HandshakeResponse:](https://dev.mysql.com/doc/dev/mysql-server/8.4.5/page_protocol_connection_phase_packets_protocol_handshake_response.html )
<img width="460" height="305" alt="Screenshot 2025-09-03 at 15 02 25"
src="https://github.com/user-attachments/assets/091bbc54-75bc-44ac-98b8-5996e8d69ed8 "
/>
Source:
https://dev.mysql.com/doc/dev/mysql-server/8.4.5/page_protocol_connection_phase.html
### How did you verify your code works?
Tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-03 18:59:15 -07:00
Ciro Spaciari
60ab798991
fix(Bun.SQL) fix timers test and disable describeWithContainer on macos ( #22382 )
...
### What does this PR do?
Actually run the Timer/TimerZ tests in CI and disable
describeWithContainer in macos
### How did you verify your code works?
CI
---------
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>
2025-09-03 17:36:03 -07:00
Alistair Smith
efdbe3b54f
bun install Security Scanner API ( #21183 )
...
### What does this PR do?
Fixes #22014
todo:
- [x] not spawn sync
- [x] better comm to subprocess (not stderr)
- [x] tty
- [x] more tests (also include some tests for the actual implementation
of a provider)
- [x] disable autoinstall?
Scanner template: https://github.com/oven-sh/security-scanner-template
<!-- **Please explain what your changes do**, example: -->
<!--
This adds a new flag --bail to bun test. When set, it will stop running
tests after the first failure. This is useful for CI environments where
you want to fail fast.
-->
---
- [x] Documentation or TypeScript types (it's okay to leave the rest
blank in this case)
- [x] Code changes
### How did you verify your code works?
<!-- **For code changes, please include automated tests**. Feel free to
uncomment the line below -->
<!-- I wrote automated tests -->
<!-- If JavaScript/TypeScript modules or builtins changed:
- [ ] I included a test for the new code, or existing tests cover it
- [ ] I ran my tests locally and they pass (`bun-debug test
test-file-name.test`)
-->
<!-- If Zig files changed:
- [ ] I checked the lifetime of memory allocated to verify it's (1)
freed and (2) only freed when it should be
- [ ] I included a test for the new code, or an existing test covers it
- [ ] JSValue used outside of the stack is either wrapped in a
JSC.Strong or is JSValueProtect'ed
- [ ] I wrote TypeScript/JavaScript tests and they pass locally
(`bun-debug test test-file-name.test`)
-->
<!-- If new methods, getters, or setters were added to a publicly
exposed class:
- [ ] I added TypeScript types for the new methods, getters, or setters
-->
<!-- If dependencies in tests changed:
- [ ] I made sure that specific versions of dependencies are used
instead of ranged or tagged versions
-->
<!-- If a new builtin ESM/CJS module was added:
- [ ] I updated Aliases in `module_loader.zig` to include the new module
- [ ] I added a test that imports the module
- [ ] I added a test that require() the module
-->
tests (bad currently)
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan-conway@users.noreply.github.com >
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-08-21 14:53:50 -07:00
Michael H
d354714791
Plugins + cross-compilation + Bun.build API support for Bun.build({compile}) ( #21915 )
...
### What does this PR do?
in the name
### How did you verify your code works?
tests, but using ci to see if anything else broke
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-08-20 01:25:49 -07:00
robobun
e7672b2d04
Add string fast path for postMessage and structuredClone ( #21926 )
...
## Summary
Implements a string fast path optimization for `postMessage` and
`structuredClone` operations that provides significant performance
improvements for string-only data transfer, along with various bug fixes
and infrastructure improvements.
## Key Performance Improvements
**postMessage with Workers:**
- **Small strings (11 chars):** ~5% faster (572ns vs 599ns)
- **Medium strings (14KB):** **~2.7x faster** (528ns vs 1.40μs)
- **Large strings (3MB):** **~660x faster** (540ns vs 356μs)
**Compared to Node.js postMessage:**
- Similar performance for small strings
- Competitive for medium strings
- **~455x faster** for large strings (540ns vs 245μs)
## Implementation Details
The optimization adds a **string fast path** that bypasses full
structured cloning serialization when:
- Input is a pure string (`value.isString()`)
- No transfer list or message ports are involved
- Not being stored persistently
### Core Changes
**String Thread-Safety Utilities (`BunString.cpp/h`):**
- `isCrossThreadShareable()` - Checks if string can be safely shared
across threads
- `toCrossThreadShareable()` - Converts strings to thread-safe form via
`isolatedCopy()`
- Handles edge cases: atoms, symbols, substring slices, external buffers
**Serialization Fast Path (`SerializedScriptValue.cpp`):**
- New `m_fastPathString` field stores string data directly
- Bypasses full object serialization machinery for pure strings
- Creates isolated copies for cross-thread safety
**Deserialization Fast Path:**
- Directly returns JSString from stored string data
- Avoids parsing serialized byte streams
**Updated Flags System (`JSValue.zig`, `Serialization.cpp`):**
- Replaces boolean `forTransfer` with structured `SerializedFlags`
- Supports `forCrossProcessTransfer` and `forStorage` distinctions
**Structured Clone Infrastructure:**
- Moved `structuredClone` implementation to dedicated
`StructuredClone.cpp`
- Added `jsFunctionStructuredCloneAdvanced` for testing with custom
flags
- Improved class serialization compatibility checks (`isForTransfer`,
`isForStorage`)
**IPC Improvements (`ipc.zig`):**
- Fixed race conditions in `SendQueue` by deferring cleanup to next tick
- Proper fd ownership handling with `bun.take()`
- Cached IPC serialize/parse functions for better performance
**BlockList Thread Safety Fixes (`BlockList.zig`):**
- Fixed potential deadlocks by moving mutex locking inside methods
- Added atomic `estimated_size` counter to avoid lock during GC
- Corrected pointer handling in comparison functions
- Improved GC safety in `rules()` method
## Benchmark Results
```
❯ bun-21926 bench/string-postmessage.mjs # This branch
postMessage(11 chars string) 572.24 ns/iter
postMessage(14 KB string) 527.55 ns/iter ← ~2.7x faster
postMessage(3 MB string) 539.70 ns/iter ← ~660x faster
❯ bun-1.2.20 bench/string-postmessage.mjs # Previous
postMessage(11 chars string) 598.76 ns/iter
postMessage(14 KB string) 1.40 µs/iter
postMessage(3 MB string) 356.38 µs/iter
❯ node bench/string-postmessage.mjs # Node.js comparison
postMessage(11 chars string) 569.63 ns/iter
postMessage(14 KB string) 1.46 µs/iter
postMessage(3 MB string) 245.46 µs/iter
```
**Key insight:** The fast path achieves **constant time performance**
regardless of string size (~540ns), while traditional serialization
scales linearly with data size.
## Test Coverage
**New Tests:**
- `test/js/web/structured-clone-fastpath.test.ts` - Fast path memory
usage validation
- `test/js/web/workers/structuredClone-classes.test.ts` - Comprehensive
class serialization tests
- Tests ArrayBuffer transferability
- Tests BunFile cloning with storage/transfer restrictions
- Tests net.BlockList cloning behavior
- Validates different serialization contexts (default, worker, window)
**Enhanced Tests:**
- `test/js/web/workers/structured-clone.test.ts` - Multi-function
testing
- Tests `structuredClone`, `jscSerializeRoundtrip`, and cross-process
serialization
- Validates consistency across different serialization paths
- `test/js/node/cluster.test.ts` - Better error handling and debugging
**Benchmarks:**
- `bench/string-postmessage.mjs` - Worker postMessage performance
comparison
- `bench/string-fastpath.mjs` - Fast path vs traditional serialization
comparison
## Bug Fixes
**BlockList Threading Issues:**
- Fixed potential deadlocks when multiple threads access BlockList
simultaneously
- Moved mutex locks inside methods rather than holding across entire
function calls
- Added atomic size tracking for GC compatibility
- Fixed comparison function pointer handling
**IPC Race Conditions:**
- Fixed race condition where `SendQueue._onAfterIPCClosed()` could be
called on wrong thread
- Deferred cleanup operations to next tick using task queue
- Improved file descriptor ownership with proper `bun.take()` usage
**Structured Clone Compatibility:**
- Enhanced class serialization with proper transfer/storage mode
checking
- Fixed edge cases where non-transferable objects were incorrectly
handled
- Added better error reporting for unsupported clone operations
## Technical Notes
- Thread safety ensured via `String.isolatedCopy()` for cross-VM
transfers
- Memory cost calculation updated to account for string references
- Maintains full compatibility with existing structured clone semantics
- Does not affect object serialization or transfer lists
- Proper cleanup and error handling throughout IPC pipeline
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.sh >
2025-08-20 00:25:00 -07:00
Jarred Sumner
d7a725952d
ci: don't include BUN_INSPECT_CONNECT_TO in bunEnv
2025-08-15 13:40:00 -07:00
Meghan Denny
b34bab745b
test: handle docker exiting with a signal ( #21512 )
2025-07-30 23:11:17 -07:00
Dylan Conway
2bc75a87f4
fix(install): fix resolving duplicate dependencies ( #21059 )
...
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-16 01:01:10 -07:00
Jarred Sumner
df7b6b4813
Add NODE_NO_WARNINGS ( #21075 )
2025-07-15 16:27:21 -07:00
Jarred Sumner
7bb9a94d68
Implement test.coveragePathIgnorePatterns ( #21013 )
...
Co-authored-by: Claude Bot <claude-bot@bun.sh >
Co-authored-by: Claude <noreply@anthropic.com >
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com >
2025-07-14 05:08:32 -07:00
Jarred Sumner
2e02d9de28
Use ReadableStream.prototype.* in tests instead of new Response(...).* ( #20937 )
...
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com >
Co-authored-by: Alistair Smith <hi@alistair.sh >
Co-authored-by: Claude Bot <claude-bot@bun.sh >
Co-authored-by: Claude <noreply@anthropic.com >
2025-07-14 00:47:53 -07:00
Alistair Smith
70c22d41d6
types: NodeJS.ProcessEnv does not extend ImportMetaEnv ( #20976 )
2025-07-11 14:16:11 -07:00
190n
8b7888aeee
[publish images] upload encrypted core dumps from CI ( #19189 )
...
Co-authored-by: 190n <7763597+190n@users.noreply.github.com >
Co-authored-by: Ashcon Partovi <ashcon@partovi.net >
2025-07-09 15:42:11 -07:00
Dylan Conway
f24e8cb98a
implement "nodeLinker": "isolated" in bun install ( #20440 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-07-09 00:19:57 -07:00
Meghan Denny
bb55b2596d
fix passing nested object to macro" ( #20497 )
...
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com >
2025-06-19 17:13:27 -07:00
Meghan Denny
d4ccba67f2
Revert "fix passing nested object to macro" ( #20495 )
2025-06-19 13:14:46 -07:00
Meghan Denny
43777cffee
fix passing nested object to macro ( #20467 )
...
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com >
2025-06-19 12:56:27 -07:00
Alistair Smith
9e329ee605
bun pm audit (#19855 )
2025-05-23 22:31:12 -07:00
Ciro Spaciari
0e883c935c
fix(install/fetch) proper handle proxy ( #19771 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com >
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com >
Co-authored-by: Meghan Denny <meghan@bun.sh >
2025-05-20 21:11:22 -07:00
Jarred Sumner
9e13a93215
[internal] Fix importing test/harness.ts without running bun install
2025-05-19 02:46:31 -07:00
Dylan Conway
428b9a92de
test ci fix ( #19483 )
2025-05-05 17:09:46 -07:00
Jarred Sumner
d8a69d6823
Enable ASAN with linux-x64-asan in CI
2025-05-02 10:44:09 -07:00
Meghan Denny
2a2247bbb6
js: fix serialization of non-transferable objects ( #19351 )
2025-04-29 18:23:26 -07:00
190n
c86097aeb0
Fix crash in require.extensions ( #18788 )
...
Co-authored-by: 190n <7763597+190n@users.noreply.github.com >
2025-04-04 19:11:32 -07:00
chloe caruso
378c68a024
fix build log missing spacee ( #18785 )
2025-04-04 15:14:33 -07:00
Don Isaac
a1ab2a4780
fix: Bun.write() with empty string creates a file ( #18561 )
2025-03-28 11:54:54 -07:00
Dylan Conway
c7edb24520
fix(install): resolution order and unused resolutions ( #18560 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-03-27 20:46:58 -07:00
Shlomo
506ea28b36
feat: load full certificate bundles from NODE_EXTRA_CA_CERTS ( #16782 )
2025-02-12 11:42:31 -08:00
Don Isaac
146ec7791b
fix(node/assert): port more test cases from node ( #16895 )
...
Co-authored-by: DonIsaac <22823424+DonIsaac@users.noreply.github.com >
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com >
2025-02-06 14:29:59 -08:00
Don Isaac
b612bc4f47
feat(node/fs): add fs.glob, fs.globSync, and fs.promises.glob ( #16676 )
2025-01-30 13:20:19 -08:00
Dylan Conway
7410da9c71
fix(install): bun.lockb -> bun.lock with incorrect optional peer dependencies ( #16743 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-01-26 04:29:54 -08:00
Dylan Conway
8e2cf8665a
fix(publish): "tarball" and "_attachment" path fix ( #16630 )
2025-01-24 18:48:42 -08:00
Don Isaac
0d53353d36
fix(node/fs): fs.close and fs.Dir.closeSync ( #16686 )
2025-01-24 05:58:07 -08:00
chloe caruso
5819fe49a7
node fs compat pr #2 ( #16422 )
...
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
Co-authored-by: Meghan Denny <meghan@bun.sh >
Co-authored-by: dylan-conway <35280289+dylan-conway@users.noreply.github.com >
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-01-21 10:28:35 -08:00
Dylan Conway
0a7cc1f1c2
Make bun.lock the default for new projects ( #16540 )
2025-01-20 23:17:52 -08:00
Jarred Sumner
54eb8233f5
Fixes expect.extend on prototypes ( #16437 )
2025-01-16 00:21:13 -08:00
Meghan Denny
e1cfea4925
node: fix the rest of test-process ( #16026 )
2025-01-06 14:30:36 -08:00
Dylan Conway
c130df6c58
start verdaccio in multiple test files ( #16118 )
2025-01-03 08:21:00 -08:00
Dylan Conway
45ca9e08c3
fix(install): peer/dev/optional = false lockfile fix ( #15874 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2024-12-20 00:34:21 -08:00
Ashcon Partovi
e8b85cff40
ci: Retry and detect flaky tests ( #15798 )
2024-12-16 17:04:33 -08:00
Dylan Conway
3df39f4bb7
bun.lock: fix --frozen-lockfile and resolving extra dependencies ( #15748 )
2024-12-13 22:40:12 -08:00
Jarred Sumner
e72692801a
[ci] Reduce number of environment variables we send ( #15730 )
2024-12-12 17:48:53 -08:00
Zack Radisic
113b62be82
Native plugin follow up ( #15632 )
...
Co-authored-by: zackradisic <zackradisic@users.noreply.github.com >
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2024-12-11 17:51:21 -08:00
Ashcon Partovi
fa6ac405a4
ci: Add bootstrap.ps1 and automate Windows build images ( #15606 )
2024-12-05 15:16:37 -07:00
pfg
bcf023c829
Implement expect().toMatchInlineSnapshot() ( #15570 )
2024-12-05 13:07:10 -08:00
dave caruso
dc01a5d6a8
feat(DevServer): batch bundles & run them asynchronously ( #15181 )
...
Co-authored-by: Ashcon Partovi <ashcon@partovi.net >
2024-11-25 18:55:47 -08:00
Jarred Sumner
8ca0eb831d
Clean up some error handling code ( #15368 )
...
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
2024-11-25 15:42:02 -08:00
Meghan Denny
797958082c
musl patches [v4] ( #15066 )
2024-11-11 19:23:58 -08:00