Skip to content
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
616a338
node:fs, node:dns, node:crypto: route a throw from a callback to unca…
cirospaciari Jul 18, 2026
2f5801c
test: vendor 7 upstream Node v26.3.0 tests that already pass
cirospaciari Jul 19, 2026
8234d7d
test: vendor three more upstream Node v26.3.0 tests
cirospaciari Jul 19, 2026
2dab5b8
test: expose more real internal modules to the vendored node suite
cirospaciari Jul 19, 2026
de4a597
test: vendor test-zlib-zstd-dictionary
cirospaciari Jul 20, 2026
f9a4610
test: remove strays swept in by a bulk add, fix Dir subtest isolation
cirospaciari Jul 20, 2026
3836440
console: move formatTime into internal/util/debuglog
cirospaciari Jul 20, 2026
60fab46
node: DEP0192/DEP0111/DEP0119 warnings and cpu-prof CLI parity
cirospaciari Jul 20, 2026
5442bd9
node:v8: heap statistics shape, cachedDataVersionTag, ERR_NOT_BUILDIN…
cirospaciari Jul 20, 2026
dfca237
node: --heap-prof CLI parity
cirospaciari Jul 20, 2026
ac412e4
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 20, 2026
a3e2c04
node:url and harness: four small compat clusters
cirospaciari Jul 20, 2026
70c8546
node compat: start up from a deleted working directory
cirospaciari Jul 20, 2026
5c544d8
node compat: process.cwd() throws ENOENT after the cwd is removed
cirospaciari Jul 20, 2026
12c23e7
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 20, 2026
f720339
node compat: module-resolution errors match node's shape
cirospaciari Jul 20, 2026
cf8ac6f
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 20, 2026
2a0e723
Merge remote-tracking branch 'origin/claude/heap-prof-cli-parity' int…
cirospaciari Jul 20, 2026
b512b57
Merge remote-tracking branch 'origin/claude/node-v8-small-gaps' into …
cirospaciari Jul 20, 2026
a80a174
Merge remote-tracking branch 'origin/claude/module-not-found-shape' i…
cirospaciari Jul 20, 2026
c59dbe3
Merge remote-tracking branch 'origin/claude/process-cwd-warn' into st…
cirospaciari Jul 20, 2026
6b4d9b6
Merge remote-tracking branch 'origin/claude/node-v26-unclaimed-freewi…
cirospaciari Jul 20, 2026
ff950bf
Fix lint and clippy errors
cirospaciari Jul 20, 2026
04ef27a
node:assert: the Assert class, and node-correct isDeepStrictEqual
cirospaciari Jul 20, 2026
701cc11
Merge remote-tracking branch 'origin/claude/assert-class-deepequal' i…
cirospaciari Jul 20, 2026
f7ecaab
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 20, 2026
0f7d0de
Remove stray test output file
cirospaciari Jul 20, 2026
7f6e602
process: latch DEP0111/DEP0119 warnings per thread, keep debuglog pri…
cirospaciari Jul 20, 2026
084afdc
Fix lint errors in merged assert code
cirospaciari Jul 20, 2026
4021c78
resolve: classify ESM specifiers host-agnostically in node error shaping
cirospaciari Jul 20, 2026
10857f8
Fix stream/iter bytes() returning Buffer, restore upstream test expec…
cirospaciari Jul 20, 2026
a1be861
stream/iter: emulate Node's Buffer pool split in concatBytes; gate ad…
cirospaciari Jul 20, 2026
8aabd9c
test: hold back test-gc-net-timeout until GC delivery timing is reliable
cirospaciari Jul 20, 2026
f9616df
cli: support node's -pe alias
cirospaciari Jul 17, 2026
088e964
cpu profiler: clamp the sampling interval to a usable range
cirospaciari Jul 21, 2026
60d6058
test: vendor test-stdout-close-catch
cirospaciari Jul 21, 2026
82c15b0
Merge origin/main into claude/callback-throw-uncaught
cirospaciari Jul 21, 2026
aef588d
module: implement Node's on-disk compile cache (NODE_COMPILE_CACHE, e…
cirospaciari Jul 21, 2026
030ad4e
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 21, 2026
0ce58c0
compile cache: satisfy clippy's collection, string, and pointer rules
cirospaciari Jul 21, 2026
28a61f2
module: support portable compile cache (NODE_COMPILE_CACHE_PORTABLE, …
cirospaciari Jul 21, 2026
4a1adaa
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 21, 2026
fb9d0f1
compile cache: log relative paths via BStr instead of from_utf8_lossy
cirospaciari Jul 21, 2026
f58d246
test: hold back test-stdout-close-catch until Windows errno mapping i…
cirospaciari Jul 21, 2026
ad15ed6
watch: add --watch-kill-signal, run kill-signal handlers before reloa…
cirospaciari Jul 21, 2026
e233e93
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 21, 2026
05f0d52
cli: display unknown signal names via BStr
cirospaciari Jul 21, 2026
a46fdd9
test: vendor 6 upstream tests that pass after the batch's fixes
cirospaciari Jul 21, 2026
1ff9ae8
async_hooks: deliver createHook lifecycle events for ticks, timers, a…
cirospaciari Jul 21, 2026
6bb13c3
node:fs: emit FSREQCALLBACK async_hooks events for callback-based fs …
cirospaciari Jul 21, 2026
8edc8a7
async_hooks: let timer emit callers own the exception check
cirospaciari Jul 21, 2026
0255ad4
process: fix v8_enable_i18n_support config key typo
cirospaciari Jul 22, 2026
75d3b84
Revert "process: fix v8_enable_i18n_support config key typo"
cirospaciari Jul 22, 2026
0c0d72a
node: expose internal/util helpers to vendored tests (+7 internal-uti…
cirospaciari Jul 22, 2026
d10e487
internal-for-testing: read the WeakReference keepalive in get()
cirospaciari Jul 22, 2026
ed09e02
process: fix v8_enable_i18n_support config key typo and the Intl test…
cirospaciari Jul 22, 2026
93cc9fc
lint: read conditionally-checked properties into locals
cirospaciari Jul 22, 2026
1a351b4
Merge origin/main into claude/callback-throw-uncaught
cirospaciari Jul 22, 2026
be6d609
event loop: wait for in-flight work-pool posters before the shutdown …
cirospaciari Jul 22, 2026
316657e
node: expose more internals to vendored tests (+20 node test files)
cirospaciari Jul 22, 2026
eef7c98
lint: split the stdio fd branches so the property is read once [allow…
cirospaciari Jul 22, 2026
4ee9319
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 22, 2026
42a6973
Address review findings: deepEquals node parity, tamper resistance, h…
cirospaciari Jul 22, 2026
e6884ca
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 22, 2026
f144512
clap: restrict short-alias rewrites to flag-shaped tokens
cirospaciari Jul 22, 2026
cefcacf
url: support the windows option in fileURLToPath
cirospaciari Jul 22, 2026
73bb684
watch: process.exit() in a kill-signal handler must not return to JS
cirospaciari Jul 22, 2026
f5c3586
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 22, 2026
3727840
style: hoist inline callbacks and cite the mirrored node sources
cirospaciari Jul 23, 2026
f1b2ffb
Address review: at-exit cache flush, windows watch signal, util arity…
cirospaciari Jul 23, 2026
769d085
url: apply the Unicode 16 IdnaMappingTable delta before ICU IDNA
cirospaciari Jul 23, 2026
2cb10f0
Merge origin/main into claude/callback-throw-uncaught
cirospaciari Jul 23, 2026
791d81c
assert,module: close review findings on map double-matching and built…
cirospaciari Jul 23, 2026
160870f
lint: drop the now-unused SafeMapPrototypeGet capture [allow size]
cirospaciari Jul 23, 2026
46bd974
module: don't latch the compile-cache exit persist on a non-fatal sel…
cirospaciari Jul 23, 2026
ed2d000
util: isDeepStrictEqual's skipPrototype third argument is public API …
cirospaciari Jul 23, 2026
e67ac08
test: harden the watch kill-signal exit test
cirospaciari Jul 23, 2026
f0717f5
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
2dee4f3
test: realign require-resolve fixture with node's module-not-found wo…
cirospaciari Jul 23, 2026
d9c6c3d
repl: stop echoing and redrawing when stdio is not a TTY
cirospaciari Jul 23, 2026
078b732
module: resolve builtins and validate paths natively in require.resolve
cirospaciari Jul 23, 2026
9c923a6
assert: native URL brand check and typed-array partial containment
cirospaciari Jul 23, 2026
3af6024
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
fd379f0
deepEquals: own-property slot reads, span comparisons, single typed-a…
cirospaciari Jul 23, 2026
d140728
util: node-exact string width and VT stripping; delete the JS width port
cirospaciari Jul 23, 2026
da36af3
assert: move the partialDeepStrictEqual comparison fully to native
cirospaciari Jul 23, 2026
392366f
address review: restore real heap snapshots, dedupe diagnostics, simd…
cirospaciari Jul 23, 2026
e2ee7d4
address review: typed-array partial props, sticky-signal map cleanup,…
cirospaciari Jul 23, 2026
8229fa2
test: remove three vendored node tests bun cannot pass yet
cirospaciari Jul 23, 2026
e6b1d63
deepEquals: reject non-enumerable matches in typed-array own-props; f…
cirospaciari Jul 23, 2026
3a7e7aa
Merge origin/main into claude/callback-throw-uncaught
cirospaciari Jul 23, 2026
311de80
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
421f4c7
assert: node-exact set items and Date/RegExp semantics in the native …
cirospaciari Jul 23, 2026
5e392de
assert: cycle-guard the Set arm of the native partial comparator
cirospaciari Jul 23, 2026
800094b
signals: map SignalCode to real Windows numbers, not Linux discriminants
cirospaciari Jul 23, 2026
7739595
test harness: merge native internal/* entries with the vendored ports
cirospaciari Jul 23, 2026
cceb8f7
assert: boxed primitives compare their internal value in the native p…
cirospaciari Jul 23, 2026
f3a0905
deepEquals: throw node's TypeError for detached DataViews on the node…
cirospaciari Jul 23, 2026
681dbfd
compile cache: drop the STATE lock during bytecode generation
cirospaciari Jul 23, 2026
9d4b9b3
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
4299728
test binding: expose getErrorMessage on the uv internalBinding
cirospaciari Jul 23, 2026
07d4b0a
test: remove test-whatwg-url-toascii until the Unicode 16 host-parsin…
cirospaciari Jul 23, 2026
cd36a54
assert/compile cache: non-index name collection; content-gate the per…
cirospaciari Jul 23, 2026
c840e44
assert: check own properties on Map/Set containers; hoist the width o…
cirospaciari Jul 23, 2026
93db111
followups: native skipPrototype/URL inspect, revert async_hooks, watc…
robobun Jul 23, 2026
e370c0c
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
79a5542
test: clear diff-hygiene grep in vendored fixtures
robobun Jul 23, 2026
af5e076
test: keep advanced-serialization and url-toascii out until #34860 / …
robobun Jul 23, 2026
20ea519
url inspect: satisfy the exception-scope validator; update Bun.inspec…
robobun Jul 23, 2026
ff6e939
ipc: preserve Buffers through advanced serialization
cirospaciari Jul 23, 2026
9f869ac
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
ea50243
review nits: constructorNameOf exception handling, dead code, ANSI wi…
robobun Jul 23, 2026
4fe89b0
url: apply the Unicode 16 IDNA delta to URL constructor and setter hosts
cirospaciari Jul 23, 2026
5dcaceb
dedup: forward ASCIILiteral customInspect to the String overload; dro…
robobun Jul 23, 2026
9c07bb3
watch: move the grace-window poll to a detached timer thread
robobun Jul 23, 2026
e787014
review: DEP0169 latch, comparator exception checks, retired-blob inva…
cirospaciari Jul 23, 2026
76f7da2
v8: preserve Buffers through serialize/deserialize
cirospaciari Jul 23, 2026
755fc98
structuredClone: share SharedArrayBuffer backing stores
cirospaciari Jul 23, 2026
f448594
watch: elect exactly one reload_process winner
cirospaciari Jul 23, 2026
8ea3aad
url: suppress DEP0169 for node_modules callers like node
cirospaciari Jul 23, 2026
9ba7fac
partial KeyObject own-props; gate IDNA delta on special schemes; DEP0…
robobun Jul 23, 2026
3aa00be
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 23, 2026
5ebab22
url: delta pre-pass covers non-canonical special-scheme authorities; …
robobun Jul 23, 2026
6964638
url: CallSite-based isInsideNodeModules for DEP0169 gating
robobun Jul 23, 2026
953fa97
watcher: retry the FileWatcher thread spawn once on transient failure
robobun Jul 24, 2026
3c7b45e
clippy: SAFETY comment on the Watcher::start unsafe; share isInsideNo…
robobun Jul 24, 2026
ab8f9dc
watcher: exit with an error (not a crash report) when FileWatcher thr…
robobun Jul 24, 2026
2f1d212
serialization_buffers: capture Object.*/Set at module load
robobun Jul 24, 2026
01bb898
url: leave same-scheme relative paths untouched by the IDNA delta pre…
robobun Jul 24, 2026
7e9cb77
url: file: only has a host with exactly two slashes; drop redundant D…
robobun Jul 24, 2026
5fe4d07
Merge origin/main into claude/callback-throw-uncaught
robobun Jul 24, 2026
f448798
fix bun_runtime build after merge: SystemError fields are now OwnedSt…
robobun Jul 24, 2026
5db6525
url: bracketed IPv6 hosts skip the IDNA delta pre-pass
robobun Jul 24, 2026
3fb2d5c
Merge origin/main; resolve bindings/inspect/util conflicts; gate v8.d…
robobun Jul 24, 2026
450022a
Merge main into claude/callback-throw-uncaught
cirospaciari Jul 25, 2026
256f7e5
watch tests: SIGKILL cleanup and a self-limiting wedge fixture
cirospaciari Jul 24, 2026
72f6d84
Merge main into claude/callback-throw-uncaught
cirospaciari Jul 25, 2026
6b93d6a
merge: drop duplicated getStringWidth export key
cirospaciari Jul 25, 2026
803231d
repl: route --interactive to the node REPL entry; width test matches …
cirospaciari Jul 25, 2026
601bbd4
review: drop duplicate DEP0192, guard boxed-string own-prop walk, sim…
robobun Jul 25, 2026
65e6776
watch: bound the kill-signal handler grace window so a wedged handler…
robobun Jul 25, 2026
4125a4a
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 25, 2026
c707a53
url: strip tab/LF/CR before locating the scheme in the IDNA delta pre…
robobun Jul 25, 2026
fa27ead
compile-cache: fetch and persist under --watch; reset signal disposit…
robobun Jul 25, 2026
066766b
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 25, 2026
83f4bf9
bindings: compare DataView own properties via nonIndexOwnPropertiesEq…
robobun Jul 25, 2026
ceb4d49
ci: retrigger
robobun Jul 26, 2026
f36c766
watch: preserve NODE_CHANNEL_FD across the reload execve
robobun Jul 26, 2026
07b0c72
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 26, 2026
17a268d
review: keep inherited SIG_IGN across reload, drop duplicate --intera…
robobun Jul 26, 2026
c0e2643
url: bound the IDNA delta span to the host so an ignored-class code p…
robobun Jul 26, 2026
b4e7a1f
c-bindings: leave JSC's RT signal and SIGSEGV/SIGBUS for execve to re…
robobun Jul 26, 2026
54cbc6e
assert: add partialDeepStrictEqual to kReadableOperator so its failur…
robobun Jul 26, 2026
c5f729f
NodeUtilTypes: align materialize lambda exception check with sibling;…
robobun Jul 26, 2026
9609332
bindings: skip the symbol-only array pass under checkPrototypes; boun…
robobun Jul 26, 2026
32b5499
compile-cache: gate persist-path display_name/format! allocations on …
robobun Jul 26, 2026
3e0523e
watch: run the pre-execve IPC/signal prep on every POSIX target
robobun Jul 26, 2026
0682b73
url: keep an empty-but-present ?/# marker on the url.format slow path
robobun Jul 26, 2026
bb0c74d
Merge origin/main into claude/callback-throw-uncaught
robobun Jul 28, 2026
af95b68
Merge origin/main into claude/callback-throw-uncaught
robobun Aug 3, 2026
075d547
merge: fix post-merge visibility and rename fallout
robobun Aug 3, 2026
48f0c16
ProcessBindingUV: use default inline capacity so spreading the bindin…
robobun Aug 3, 2026
5529375
shared: capture Error.captureStackTrace at module load and catch tamp…
robobun Aug 3, 2026
5afa23a
crypto: revert pbkdf2 then-handlers to inline arrows
robobun Aug 3, 2026
276e176
Merge remote-tracking branch 'origin/main' into claude/callback-throw…
robobun Aug 3, 2026
3961f52
merge: fix bun_jsc::cpp path in ipc.rs; skip sigThreadSuspendResume (…
robobun Aug 3, 2026
53ca0e7
shared: move the Error.stackTraceLimit/prepareStackTrace reads inside…
robobun Aug 3, 2026
1bf82f5
trim comments to <=3 lines, cite spec/node source
robobun Aug 3, 2026
5006828
shared: wrap the isInsideNodeModules frame loop in try/catch so a poi…
robobun Aug 3, 2026
7c59080
url: ERR_INVALID_URL carries error.base when base argument given
robobun Aug 4, 2026
d829edc
Merge remote-tracking branch 'origin/main' into claude/callback-throw…
robobun Aug 4, 2026
aa34871
serialization_buffers: walk Map/Set via .$forEach so a poisoned Symbo…
robobun Aug 4, 2026
44804fe
serialization_buffers: use own-property hasOwnProperty.$call for the …
robobun Aug 4, 2026
5c9ddf8
chore: reword 'ungated' in shutdown-drain comments to pass port-era-m…
robobun Aug 4, 2026
dbfbd55
serialization_buffers: use indexed-access pop + $arrayPush for the wa…
robobun Aug 4, 2026
7837a3a
Merge branch 'main' into claude/callback-throw-uncaught
cirospaciari Aug 5, 2026
d0a7db1
dispatch: bump task-tag arm count for WatchReloadTask after merge
cirospaciari Aug 5, 2026
c193c29
JSDOMURL: derive URLContext search/hash offsets from the href; drop d…
robobun Aug 5, 2026
6f71d8c
url: emit the /. guard in formatWhatwgURL for null-host paths startin…
robobun Aug 5, 2026
0c27355
Merge branch 'main' into callback-throw-uncaught
cirospaciari Aug 6, 2026
4a4caed
ipc: bump advanced wire version to 2 for SerializedMessageWithBuffers
robobun Aug 6, 2026
9194b29
JSDOMURL: shift URLContext offsets past the /. pathname guard
robobun Aug 6, 2026
10b12bd
compile cache: key and verify entries with SHA256, mmap the read path
robobun Aug 7, 2026
3f9fef3
Merge branch 'main' into callback-throw-uncaught
robobun Aug 7, 2026
2faf71c
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 7, 2026
effa0cb
Route byte searches through bun_core::strings; persist compile cache …
robobun Aug 7, 2026
66b925e
node:v8: capture envelope framing dependencies at module load
robobun Aug 7, 2026
d8a3b9c
compile cache: default dir checks TEMP before TMP on Windows, like os…
robobun Aug 7, 2026
aaaecbe
Declare the IDNA helpers once in NodeURLHelpers.h
robobun Aug 7, 2026
53f2e7a
Merge remote-tracking branch 'origin/main' into claude/callback-throw…
robobun Aug 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions docs/project/benchmarking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,19 @@ bun --cpu-prof --cpu-prof-dir ./profiles script.js

## Heap profiling

Generate heap snapshots on exit to analyze memory usage and find memory leaks.
Write a heap profile on exit to analyze memory usage and find memory leaks.

```sh terminal icon="terminal"
bun --heap-prof script.js
```

`--heap-prof` writes a V8 `.heapsnapshot` file you can load in Chrome DevTools (Memory tab → Load).
`--heap-prof` writes a `.heapprofile` file using Node.js's filename format
(`Heap.<yyyymmdd>.<hhmmss>.<pid>.<tid>.<seq>.heapprofile`). JavaScriptCore does not
sample allocation call stacks, so the profile reports the live heap size on the
`(root)` frame rather than a per-function allocation tree.

For a full heap snapshot you can load in Chrome DevTools (Memory tab → Load), use
`v8.writeHeapSnapshot()` or `Bun.generateHeapSnapshot("v8")` instead.
Comment thread
cirospaciari marked this conversation as resolved.
Outdated

### Markdown output

Expand All @@ -282,13 +288,14 @@ bun --heap-prof-md script.js
### Options

```sh terminal icon="terminal"
bun --heap-prof --heap-prof-name my-snapshot.heapsnapshot script.js
bun --heap-prof --heap-prof-name my-profile.heapprofile script.js
bun --heap-prof --heap-prof-dir ./profiles script.js
```

| Flag | Description |
| ----------------------------- | ------------------------------------------ |
| `--heap-prof` | Generate a V8 `.heapsnapshot` file on exit |
| `--heap-prof-md` | Generate a markdown heap profile on exit |
| `--heap-prof-name <filename>` | Set output filename |
| `--heap-prof-dir <dir>` | Set output directory |
| Flag | Description |
| ------------------------------ | ------------------------------------------------------------ |
| `--heap-prof` | Write a `.heapprofile` file on exit |
| `--heap-prof-md` | Generate a markdown heap profile on exit |
| `--heap-prof-name <filename>` | Set output filename |
| `--heap-prof-dir <dir>` | Set output directory |
| `--heap-prof-interval <bytes>` | Accepted for Node.js compatibility (sampling is unsupported) |
6 changes: 6 additions & 0 deletions docs/runtime/watch-mode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ bun --watch test
--no-clear-screen`.
</Note>

<Note>
Before each restart, `bun run --watch` runs the handlers your script registered for the kill signal (default
`SIGTERM`, matching the signal Node.js sends its watched process). Use **`--watch-kill-signal`** to pick a different
signal, e.g. `bun --watch --watch-kill-signal SIGINT index.ts`.
</Note>

---

## `--hot` mode
Expand Down
4 changes: 4 additions & 0 deletions docs/snippets/cli/run.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ bun run <file or script>
Automatically restart the process on file change
</ParamField>

<ParamField path="--watch-kill-signal" type="string" default="SIGTERM">
Signal whose handlers run when --watch restarts the process
</ParamField>

<ParamField path="--hot" type="boolean">
Enable auto reload in the Bun runtime, test runner, or bundler
</ParamField>
Expand Down
Binary file added garbage-env
Binary file not shown.
54 changes: 54 additions & 0 deletions src/bun_core/Global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,60 @@ macro_rules! __define_signal_code {
}
for_each_signal!(__define_signal_code);

impl SignalCode {
/// This table uses Linux numbering; returns the current platform's number
/// (they differ on macOS/BSD), or `None` when the platform lacks the signal.
pub fn platform_number(self) -> Option<i32> {
#[cfg(unix)]
{
use SignalCode as S;
Some(match self {
S::SIGHUP => libc::SIGHUP,
S::SIGINT => libc::SIGINT,
S::SIGQUIT => libc::SIGQUIT,
S::SIGILL => libc::SIGILL,
S::SIGTRAP => libc::SIGTRAP,
S::SIGABRT => libc::SIGABRT,
S::SIGBUS => libc::SIGBUS,
S::SIGFPE => libc::SIGFPE,
S::SIGKILL => libc::SIGKILL,
S::SIGUSR1 => libc::SIGUSR1,
S::SIGSEGV => libc::SIGSEGV,
S::SIGUSR2 => libc::SIGUSR2,
S::SIGPIPE => libc::SIGPIPE,
S::SIGALRM => libc::SIGALRM,
S::SIGTERM => libc::SIGTERM,
S::SIG16 => return None,
S::SIGCHLD => libc::SIGCHLD,
S::SIGCONT => libc::SIGCONT,
S::SIGSTOP => libc::SIGSTOP,
S::SIGTSTP => libc::SIGTSTP,
S::SIGTTIN => libc::SIGTTIN,
S::SIGTTOU => libc::SIGTTOU,
S::SIGURG => libc::SIGURG,
S::SIGXCPU => libc::SIGXCPU,
S::SIGXFSZ => libc::SIGXFSZ,
S::SIGVTALRM => libc::SIGVTALRM,
S::SIGPROF => libc::SIGPROF,
S::SIGWINCH => libc::SIGWINCH,
S::SIGIO => libc::SIGIO,
#[cfg(target_os = "linux")]
S::SIGPWR => libc::SIGPWR,
#[cfg(not(target_os = "linux"))]
S::SIGPWR => return None,
S::SIGSYS => libc::SIGSYS,
})
}
#[cfg(not(unix))]
{
match self {
Self::SIG16 => None,
_ => Some(self as u8 as i32),
}
Comment thread
cirospaciari marked this conversation as resolved.
}
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// ─── analytics::features (MOVE_DOWN from bun_analytics) ───────────────────
// Atomic counters so cross-thread `.fetch_add` is sound. Only the
// counters are tier-0; `builtin_modules` (EnumSet over jsc HardcodedModule)
Expand Down
5 changes: 5 additions & 0 deletions src/bun_core/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ new!(pub NODE_CHANNEL_FD: string, "NODE_CHANNEL_FD", {});
// A string, not a boolean: node suppresses warnings only when the value is
// exactly "1" (lib/internal/process/pre_execution.js).
new!(pub NODE_NO_WARNINGS: string, "NODE_NO_WARNINGS", {});
new!(pub NODE_COMPILE_CACHE: string, "NODE_COMPILE_CACHE", {});
new!(pub NODE_COMPILE_CACHE_PORTABLE: string, "NODE_COMPILE_CACHE_PORTABLE", {});
new!(pub NODE_DEBUG_NATIVE: string, "NODE_DEBUG_NATIVE", {});
new!(pub NODE_DISABLE_COMPILE_CACHE: string, "NODE_DISABLE_COMPILE_CACHE", {});
// Set by HostProcess.rs when spawning the WebView host subprocess. The
// child's CLI entrypoint checks this before anything else and hands off to
// C++ Bun__WebView__hostMain. Never returns — no JSC, no VM.
new!(pub BUN_INTERNAL_WEBVIEW_HOST: string, "BUN_INTERNAL_WEBVIEW_HOST", {});
new!(pub NODE_PENDING_DEPRECATION: string, "NODE_PENDING_DEPRECATION", {});
new!(pub NODE_PRESERVE_SYMLINKS_MAIN: boolean, "NODE_PRESERVE_SYMLINKS_MAIN", { default: false });
new!(pub NODE_USE_SYSTEM_CA: boolean, "NODE_USE_SYSTEM_CA", { default: false });
new!(pub npm_lifecycle_event: string, "npm_lifecycle_event", {});
Expand Down
3 changes: 3 additions & 0 deletions src/bun_core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2601,6 +2601,9 @@ pub mod ffi {
unsafe impl Zeroable for libc::pollfd {}
// SAFETY: C POD (integer/array/raw-pointer fields only); all-zero is valid.
#[cfg(unix)]
unsafe impl Zeroable for libc::tm {}
// SAFETY: C POD (integer/array/raw-pointer fields only); all-zero is valid.
#[cfg(unix)]
unsafe impl Zeroable for libc::Dl_info {}
// SAFETY: C POD (integer/array/raw-pointer fields only); all-zero is valid.
#[cfg(unix)]
Expand Down
33 changes: 30 additions & 3 deletions src/bun_core/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4247,6 +4247,34 @@ pub fn intern_argv(v: Vec<&'static ZStr>) -> &'static [&'static ZStr] {
/// Writes the current working directory into the caller's `PathBuffer` and
/// returns the NUL-terminated slice on success.
pub fn getcwd(buf: &mut PathBuffer) -> crate::CrateResult<&ZStr> {
let len = getcwd_len(buf)?;
Ok(ZStr::from_buf(&buf.0, len))
}

/// `getcwd` tolerating an unreachable cwd (e.g. deleted while we run): falls
/// back to the executable's directory like Node's `Environment::GetCwd`, so
/// startup proceeds and `process.cwd()` surfaces the real error later.
pub fn getcwd_or_exe_dir(buf: &mut PathBuffer) -> &ZStr {
let len = match getcwd_len(buf) {
Ok(n) => n,
Err(_) => {
let dir: &[u8] = self_exe_path()
.ok()
.and_then(|p| dirname(p.as_bytes()))
// Reject a dir that can't fit with its NUL (paths from
// /proc/self/exe are not bounded by MAX_PATH_BYTES).
.filter(|d| d.len() < buf.0.len())
.unwrap_or(if cfg!(windows) { b"C:\\" } else { b"/" });
buf.0[..dir.len()].copy_from_slice(dir);
buf.0[dir.len()] = 0;
dir.len()
}
};
ZStr::from_buf(&buf.0, len)
}

/// Length-returning core of [`getcwd`]; `buf` holds the NUL-terminated path.
fn getcwd_len(buf: &mut PathBuffer) -> crate::CrateResult<usize> {
#[cfg(unix)]
// SAFETY: `buf` provides `MAX_PATH_BYTES` writable bytes for `getcwd`; on
// success the returned pointer aliases `buf` and is NUL-terminated, so
Expand All @@ -4256,8 +4284,7 @@ pub fn getcwd(buf: &mut PathBuffer) -> crate::CrateResult<&ZStr> {
if p.is_null() {
return Err(crate::CrateError::Unexpected);
}
let len = libc::strlen(p);
Ok(ZStr::from_buf(&buf.0, len))
Ok(libc::strlen(p))
}
#[cfg(windows)]
{
Expand Down Expand Up @@ -4293,7 +4320,7 @@ pub fn getcwd(buf: &mut PathBuffer) -> crate::CrateResult<&ZStr> {
bi += nb;
}
out[bi] = 0;
Ok(ZStr::from_buf(&buf.0[..], bi))
Ok(bi)
}
#[cfg(not(any(unix, windows)))]
{
Expand Down
1 change: 1 addition & 0 deletions src/clap/comptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ impl<Id> ComptimeClap<Id> {
diagnostic: opt.diagnostic,
state: streaming::State::Normal,
positional: None,
short_aliases: opt.short_aliases,
};

while let Some(arg) = stream.next()? {
Expand Down
6 changes: 6 additions & 0 deletions src/clap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ impl Default for Help {
pub struct ParseOptions<'a> {
pub diagnostic: Option<&'a mut Diagnostic>,
pub stop_after_positional_at: usize,
/// Whole-token rewrites applied only where a token is being classified as a
/// flag, never to an option's value or a `--` target. Node keeps its own
/// aliases on exactly that branch (node_options-inl.h).
pub short_aliases: &'static [(&'static [u8], &'static [u8])],
}

// Help/usage/error rendering — none of this is on the cold-start hot chain
Expand Down Expand Up @@ -506,6 +510,7 @@ pub fn parse<Id: 'static>(
ParseOptions {
diagnostic: opt.diagnostic,
stop_after_positional_at: opt.stop_after_positional_at,
short_aliases: opt.short_aliases,
},
)?;
Ok(Args { clap, exe_arg })
Expand All @@ -526,6 +531,7 @@ pub fn parse_with_table<Id: 'static>(
ParseOptions {
diagnostic: opt.diagnostic,
stop_after_positional_at: opt.stop_after_positional_at,
short_aliases: opt.short_aliases,
},
)?;
Ok(Args { clap, exe_arg })
Expand Down
18 changes: 17 additions & 1 deletion src/clap/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct StreamingClap<'p, 'a, Id, ArgIterator> {
pub state: State<'a>,
pub positional: Option<&'p clap::Param<Id>>,
pub diagnostic: Option<&'p mut clap::Diagnostic>,
pub short_aliases: &'static [(&'static [u8], &'static [u8])],
}

// ArgIterator is the
Expand Down Expand Up @@ -300,9 +301,22 @@ where
}

fn parse_next_arg(&mut self) -> Result<Option<ArgInfo<'a>>, ArgError> {
let Some(full_arg) = self.iter.next() else {
let Some(mut full_arg) = self.iter.next() else {
return Ok(None);
};
// Only tokens reaching here are being read as flags: option values and
// `--` targets are pulled straight off `iter`, so they stay verbatim.
// Restrict rewrites to flag-shaped tokens so a mapping can never touch
// the `-`/`--` sentinels or a positional, per the contract on
// `ParseOptions::short_aliases`.
if full_arg.starts_with(b"-") && full_arg != b"-" && full_arg != b"--" {
for (from, to) in self.short_aliases {
if full_arg == *from {
full_arg = to;
break;
}
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if full_arg == b"--" || full_arg == b"-" {
return Ok(Some(ArgInfo {
arg: full_arg,
Expand Down Expand Up @@ -354,6 +368,7 @@ mod tests {
remain: args_strings,
};
let mut c = StreamingClap::<u8, args::SliceIterator> {
short_aliases: &[],
params,
iter: &mut iter,
state: State::Normal,
Expand Down Expand Up @@ -386,6 +401,7 @@ mod tests {
remain: args_strings,
};
let mut c = StreamingClap::<u8, args::SliceIterator> {
short_aliases: &[],
params,
iter: &mut iter,
state: State::Normal,
Expand Down
5 changes: 5 additions & 0 deletions src/codegen/class-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ export class ClassDefinition {
* The instances of this class are intended to be inside the this of a bound function.
*/
forBind?: boolean;
/**
* Parent of the generated prototype object. "Error" puts Error.prototype in
* the chain so instances satisfy `instanceof Error`. Default: Object.prototype.
*/
prototypeBase?: "Error";
/**
* ## IMPORTANT
* You _must_ free the pointer to your native class!
Expand Down
8 changes: 7 additions & 1 deletion src/codegen/generate-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,13 @@ ${

JSObject* ${name}::createPrototype(VM& vm, JSDOMGlobalObject* globalObject)
{
auto *structure = ${prototypeName(typeName)}::createStructure(vm, globalObject, ${obj.forBind ? "globalObject->functionPrototype()" : "globalObject->objectPrototype()"});
auto *structure = ${prototypeName(typeName)}::createStructure(vm, globalObject, ${
obj.forBind
? "globalObject->functionPrototype()"
: obj.prototypeBase === "Error"
? "globalObject->errorPrototype()"
: "globalObject->objectPrototype()"
});
structure->setMayBePrototype(true);
return ${prototypeName(typeName)}::create(vm, globalObject, structure);
}
Expand Down
56 changes: 30 additions & 26 deletions src/errno/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,40 @@ macro_rules! __decl_uv_e {
( $( $ident:ident = $value:expr => $display:literal ),+ $(,)? ) => {
$( pub const $ident: i32 = $value; )+

/// The full (negated code, name) table for this target —
/// target-independent libuv-synthetic codes (values from
/// vendor/libuv/include/uv/errno.h) first, then the per-OS rows.
/// Consumed by `name()` and node:util's `getSystemErrorMap()`.
pub static ENTRIES: &[(i32, &'static str)] = &[
(-4095, "EOF"),
(-4094, "UNKNOWN"),
(-3000, "EAI_ADDRFAMILY"),
(-3001, "EAI_AGAIN"),
(-3002, "EAI_BADFLAGS"),
(-3003, "EAI_CANCELED"),
(-3004, "EAI_FAIL"),
(-3005, "EAI_FAMILY"),
(-3006, "EAI_MEMORY"),
(-3007, "EAI_NODATA"),
(-3008, "EAI_NONAME"),
(-3009, "EAI_OVERFLOW"),
(-3010, "EAI_SERVICE"),
(-3011, "EAI_SOCKTYPE"),
(-3013, "EAI_BADHINTS"),
(-3014, "EAI_PROTOCOL"),
$( (-($ident), $display) ),+
];

/// Negated libuv error code (`-UV_E*`) → user-visible name.
/// `None` for unmapped values (caller falls back to
/// `"Unknown system error N"`). Input is the raw signed value as
/// returned to JS — i.e. `-uv_e::FOO`.
/// `"Unknown system error N"`). First match wins, mirroring the
/// duplicate-value tolerance of the old `if`-chain (EAGAIN aliases).
pub fn name(neg_uv_err: i32) -> Option<&'static str> {
// Target-independent libuv-synthetic codes (no `uv_e::*` const).
// Values from vendor/libuv/include/uv/errno.h.
match neg_uv_err {
-4095 => return Some("EOF"),
-4094 => return Some("UNKNOWN"),
-3000 => return Some("EAI_ADDRFAMILY"),
-3001 => return Some("EAI_AGAIN"),
-3002 => return Some("EAI_BADFLAGS"),
-3003 => return Some("EAI_CANCELED"),
-3004 => return Some("EAI_FAIL"),
-3005 => return Some("EAI_FAMILY"),
-3006 => return Some("EAI_MEMORY"),
-3007 => return Some("EAI_NODATA"),
-3008 => return Some("EAI_NONAME"),
-3009 => return Some("EAI_OVERFLOW"),
-3010 => return Some("EAI_SERVICE"),
-3011 => return Some("EAI_SOCKTYPE"),
-3013 => return Some("EAI_BADHINTS"),
-3014 => return Some("EAI_PROTOCOL"),
_ => {}
for &(code, name) in ENTRIES {
if code == neg_uv_err {
return Some(name);
}
}
// Per-OS rows. `if`-chain (not `match`) because two `$value`s may
// resolve to the same integer on some targets (e.g. EAGAIN ==
// EWOULDBLOCK), which `match` rejects as an unreachable pattern.
$( if neg_uv_err == -($ident) { return Some($display); } )+
None
}
};
Expand Down
1 change: 1 addition & 0 deletions src/event_loop/ConcurrentTask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub mod task_tag {
Futimes,
GetAddrInfoRequestTask,
HotReloadTask,
WatchReloadTask,
ImmediateObject,
JSCDeferredWorkTask,
Lchmod,
Expand Down
Loading
Loading