Commit Graph

106 Commits

Author SHA1 Message Date
Alistair Smith
1d50af7fe8 @types/bun: Update to @types/node@25, fallback to PropertyKey in test expect matchers when keyof unknown is used (#25460)
more accurately, developers cannot pass a value when expect values
resolve to never. this is easy to fall into when using the
`toContainKey*` matchers. falling back to PropertyKey when this happens
is a sensible/reasonable default

### What does this PR do?

fixes #25456, cc @MonsterDeveloper
fixes #25461

### How did you verify your code works?

bun types integration test
2025-12-10 18:15:55 -08:00
Zack Radisic
a89e61fcaa ssg 3 (#22138)
### What does this PR do?

Fixes a crash related to the dev server overwriting the uws user context
pointer when setting abort callback.

Adds support for `return new Response(<jsx />, { ... })` and `return
Response.render(...)` and `return Response.redirect(...)`:
- Created a `SSRResponse` class to handle this (see
`JSBakeResponse.{h,cpp}`)
- `SSRResponse` is designed to "fake" being a React component 
- This is done in JSBakeResponse::create inside of
src/bun.js/bindings/JSBakeResponse.cpp
- And `src/js/builtins/BakeSSRResponse.ts` defines a `wrapComponent`
function which wraps
the passed in component (when doing `new Response(<jsx />, ...)`). It
does
    this to throw an error (in redirect()/render() case) or return the
    component.
- Created a `BakeAdditionsToGlobal` struct which contains some
properties
    needed for this
- Added some of the properties we need to fake to BunBuiltinNames.h
(e.g.
    `$$typeof`), the rationale behind this is that we couldn't use
`structure->addPropertyTransition` because JSBakeResponse is not a final
    JSObject.
- When bake and server-side, bundler rewrites `Response ->
Bun.SSRResponse` (see `src/ast/P.zig` and `src/ast/visitExpr.zig`)
- Created a new WebCore body variant (`Render: struct { path: []const u8
}`)
  - Created when `return Response.render(...)`
  - When handled, it re-invokes dev server to render the new path

Enables server-side sourcemaps for the dev server:
- New source providers for server-side:
(`DevServerSourceProvider.{h,cpp}`)
- IncrementalGraph and SourceMapStore are updated to support this

There are numerous other stuff:
- allow `app` configuration from Bun.serve(...)
- fix errors stopping dev server
- fix use after free related to in
RequestContext.finishRunningErrorHandler
- Request.cookies
- Make `"use client";` components work
- Fix some bugs using `require(...)` in dev server
- Fix catch-all routes not working in the dev server
- Updates `findSourceMappingURL(...)` to use `std.mem.lastIndexOf(...)`
because
  the sourcemap that should be used is the last one anyway

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Alistair Smith <hi@alistair.sh>
2025-09-30 05:26:32 -07:00
Ciro Spaciari
85271f9dd9 fix(node:http) allow CONNECT in node http/https servers (#22756)
### What does this PR do?
Fixes https://github.com/oven-sh/bun/issues/22755
Fixes https://github.com/oven-sh/bun/issues/19790
Fixes https://github.com/oven-sh/bun/issues/16372
### How did you verify your code works?

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-23 16:46:59 -07:00
Jarred Sumner
d957a81c0a Revert "Fix RSA JWK import validation bug causing Jose library failures" (#22307)
Test did not fail in previous build of Bun

Reverts oven-sh/bun#22264
2025-09-01 02:45:01 -07:00
robobun
0b98086c3d Fix RSA JWK import validation bug causing Jose library failures (#22264)
## Summary

- Fixed a typo in RSA JWK import validation in
`CryptoKeyRSA::importJwk()`
- The bug was checking `keyData.dp.isNull()` twice instead of checking
`keyData.dq.isNull()`
- This caused valid RSA private keys with Chinese Remainder Theorem
parameters to be incorrectly rejected
- Adds comprehensive regression tests for RSA JWK import functionality
- Adds `jose@5.10.0` dependency to test suite for proper integration
testing

## Background

Issue #22257 reported that the Jose library (popular JWT library) was
failing in Bun with a `DataError: Data provided to an operation does not
meet requirements` when importing valid RSA JWK keys that worked fine in
Node.js and browsers.

## Root Cause

In `src/bun.js/bindings/webcrypto/CryptoKeyRSA.cpp` line 69, the
validation logic had a typo:

```cpp
// BEFORE (incorrect)
if (keyData.p.isNull() && keyData.q.isNull() && keyData.dp.isNull() && keyData.dp.isNull() && keyData.qi.isNull()) {

// AFTER (fixed) 
if (keyData.p.isNull() && keyData.q.isNull() && keyData.dp.isNull() && keyData.dq.isNull() && keyData.qi.isNull()) {
```

This meant that RSA private keys with CRT parameters (which include `p`,
`q`, `dp`, `dq`, `qi`) would incorrectly fail validation because `dq`
was never actually checked.

## Test plan

- [x] Reproduces the original Jose library issue
- [x] Compares behavior with Node.js to confirm the fix  
- [x] Tests RSA JWK import with full private key (including CRT
parameters)
- [x] Tests RSA JWK import with public key
- [x] Tests RSA JWK import with minimal private key (n, e, d only)
- [x] Tests Jose library integration after the fix
- [x] Added `jose@5.10.0` to test dependencies with proper top-level
import

**Note**: The regression tests currently fail against the existing debug
build since they validate the fix that needs to be compiled. They will
pass once the C++ changes are built into the binary. The fix has been
verified to work by reproducing the issue, comparing with Node.js
behavior, and identifying the exact typo causing the validation failure.

The fix is minimal, targeted, and resolves a clear compatibility gap
with the Node.js ecosystem.

🤖 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>
2025-09-01 02:43:44 -07:00
Jarred Sumner
4fa69773a3 Introduce Bun.stripANSI (#21801)
### What does this PR do?

Introduce `Bun.stripANSI`, a SIMD-accelerated drop-in replacement for
the popular `"strip-ansi"` package.

`Bun.stripANSI` performs >10x faster and fixes several bugs in
`strip-ansi`, like [this long-standing
one](https://github.com/chalk/strip-ansi/issues/43).

### How did you verify your code works?

There are tests that check the output of `strip-ansi` matches
`Bun.stripANSI`. For cases where `strip-ansi`'s behavior is incorrect,
the expected value is manually provided.

---------

Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: taylor.fish <contact@taylor.fish>
2025-08-14 22:42:05 -07:00
Jarred Sumner
964d4dac2c Rewrite AbortSignal.timeout (#21695)
### 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>
2025-08-08 23:07:19 -07:00
Alistair Smith
d0edcc69ae Support TypeScript 5.9 (#21539)
### What does this PR do?

Fixes #21535

### How did you verify your code works?
2025-08-01 16:09:44 -07:00
pfg
0cf2b71ff1 expect.toHaveReturnedWith/toHaveLastReturnedWith/toHaveNthReturnedWith (#21363)
Fixes #10380

DRAFT: not reviewed

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-01 15:09:03 -07:00
Dylan Conway
1a9bc5da09 fix(install): isolated install aliased dependency name fix (#21138)
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: Ciro Spaciari <ciro.spaciari@gmail.com>
Co-authored-by: Meghan Denny <meghan@bun.sh>
2025-07-19 01:59:52 -07:00
Jarred Sumner
45e97919e5 Add bun bd to test/ folder and also run formatter 2025-07-17 22:20:02 -07:00
Alistair Smith
65ccb39778 Convert bun-types.test.ts to TS compiler api, fix forward-declared empty interfaces (#20960) 2025-07-10 22:47:42 -07:00
Jarred Sumner
27c979129c Introduce Bun.randomUUIDv5 (#20782)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: jarred <jarred@bun.sh>
Co-authored-by: Meghan Denny <meghan@bun.sh>
2025-07-02 22:47:14 -07:00
Ciro Spaciari
a04cf04cd5 fix(grpc/http2) fix tonic Rust support (#20738)
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-07-02 17:43:38 -07:00
190n
172aecb02e [publish images] Upgrade self-reported Node.js version from 22.6.0 to 24.3.0 (v2) (#20772)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: pfg <pfg@pfg.pw>
Co-authored-by: pfgithub <6010774+pfgithub@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-07-02 12:06:08 -07:00
Ben Grant
ea57037567 Revert "Upgrade self-reported Node.js version from 22.6.0 to 24.3.0 (#20659) [publish images]"
This reverts commit 80309e4d59. It breaks the Windows CI.
2025-07-02 09:40:32 -07:00
Jarred Sumner
80309e4d59 Upgrade self-reported Node.js version from 22.6.0 to 24.3.0 (#20659) [publish images]
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: pfg <pfg@pfg.pw>
Co-authored-by: pfgithub <6010774+pfgithub@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: Ben Grant <ben@bun.sh>
2025-07-02 00:03:05 -07:00
Ciro Spaciari
4cea70a484 fix(node:http) fix fastify websockets (#18712) 2025-04-01 19:28:44 -07:00
Ciro Spaciari
7021c42cf2 fix(node:http) fix post regression (#18599)
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2025-03-29 01:50:26 -07:00
Don Isaac
75144ab881 fix: reflect-metadata import order (#18086)
Co-authored-by: DonIsaac <22823424+DonIsaac@users.noreply.github.com>
2025-03-26 16:19:45 -07:00
Meghan Denny
66fb9f1097 test: install detect-libc (#18185) 2025-03-14 09:49:19 -07:00
Don Isaac
a41d773aaa feat: support Svelte in bundler and dev server (#17735) 2025-03-04 14:16:18 -08:00
Don Isaac
70dbf582a6 fix(bunfig): fix and test preloads (#16329) 2025-03-03 15:45:18 -08:00
Ciro Spaciari
5c6e20aeb4 fix(sql) fix state being set to prepared too soon (#17732) 2025-02-26 16:02:51 -08:00
Jarred Sumner
c2a9cf5bbd Fixes #17568 (#17572) 2025-02-22 16:48:20 -08:00
190n
7c6d9cac50 Bump WebKit, re-enable IPInt (#17467) 2025-02-19 20:47:40 -08:00
chloe caruso
f17ce2b756 hmr fixes (#17239)
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-02-12 23:14:02 -08:00
190n
4d2a8650e5 test: bump pglite version (#17117) 2025-02-06 14:33:44 -08:00
190n
af27f9e697 Allow WTF timers to participate in the event loop (#15557)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: 190n <190n@users.noreply.github.com>
Co-authored-by: 190n <7763597+190n@users.noreply.github.com>
2025-01-28 17:47:53 -08:00
190n
71eb1476db Fix crash when napi_register_module_v1 returns nullptr (#16816) 2025-01-27 20:13:22 -08:00
pfg
1fd7ed6751 Fix typescript emitDecoratorMetadata for getters (#16389)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-01-20 22:14:04 -08:00
pfg
b04ce670e3 Fix #16312 (#16322)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-01-10 20:04:16 -08:00
Jarred Sumner
5e003dccd2 Fixes #16277 (#16280) 2025-01-09 03:15:31 -08:00
190n
8268af3a7d Disable IPInt (#16188) 2025-01-06 13:59:50 -08:00
Jarred Sumner
f834304c27 Support generating V8 Heap Snapshots (#16109) 2025-01-02 20:15:13 -08:00
Jarred Sumner
10990f5213 Fixes #3554 (#15870) 2024-12-18 22:54:11 -08:00
190n
59e06b0df5 fix(napi): set lossless parameter in napi_get_value_bigint_{int64,uint64}, and trim leading zeroes in napi_create_bigint_words (#15804) 2024-12-17 17:38:12 -08:00
190n
4eae3a90e8 fix(napi): Make napi_wrap work on regular objects (#15622)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-12-16 15:54:39 -08:00
Ashcon Partovi
fa6ac405a4 ci: Add bootstrap.ps1 and automate Windows build images (#15606) 2024-12-05 15:16:37 -07:00
dave caruso
baff3c900e bake: fix the big regressions (#15544)
Co-authored-by: paperdave <paperdave@users.noreply.github.com>
2024-12-03 22:15:59 -08:00
Ciro Spaciari
c04a2d1dfc fix regression on http2-wrapper caused by node.js compatibility improvements on net (#15318) 2024-11-22 15:22:35 -08:00
Jarred Sumner
3ef35d746a Implement junit test reporter (#15205)
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2024-11-18 20:50:42 -08:00
Zack Radisic
5502278f3e CSS: More stuff and tests (#14832)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-10-27 13:49:25 -07:00
Ciro Spaciari
409e674526 feat(node:http2) Implement HTTP2 server support (#14286)
Co-authored-by: cirospaciari <cirospaciari@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-10-15 16:28:21 -07:00
Dylan Conway
3452f50c96 update webkit (#14449) 2024-10-10 02:35:23 -07:00
Dylan Conway
f374ae6db1 add bun publish (#14215) 2024-10-02 20:47:22 -07:00
Ciro Spaciari
d80d9f450c fix(node:http) improve agent support (#13780)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-09-19 23:04:36 -07:00
Meghan Denny
de5809b45a windows: fix sometimes crash when FDImpl.uv() is called on stdio (#13719)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Dave Caruso <me@paperdave.net>
Co-authored-by: nektro <nektro@users.noreply.github.com>
2024-09-06 21:00:55 -07:00
Ashcon Partovi
a1312066b3 Fix secrets in CI tests (#13306) 2024-08-14 11:13:09 -07:00
Jarred Sumner
6ad3e6a5e3 Fixes #2532 (#12633)
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
2024-07-17 20:53:12 -07:00