Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 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
d10009e
tls: move translatePeerCertificate into internal/tls/common
cirospaciari Jul 24, 2026
d9b72de
util: support util.deprecate(fn, msg, code, { modifyPrototype })
cirospaciari Jul 24, 2026
3cf72ef
events: node-compatible Event inspection and CustomEvent options error
cirospaciari Jul 24, 2026
dd849ba
dns: match node 26 argument validation and stop caching answers
cirospaciari Jul 24, 2026
8899a9c
timers: add internal setUnrefTimeout helper
cirospaciari Jul 24, 2026
20a86d4
test: drop test-dns-lookup.js from this branch
cirospaciari Jul 24, 2026
3d5953d
[autofix.ci] apply automated fixes
autofix-ci[bot] Jul 24, 2026
ba1ba07
test: re-sync test-dns-lookup.js with upstream v26.3.0
cirospaciari Jul 24, 2026
b3c233b
dns: reject unknown rrtypes with node's ERR_INVALID_ARG_VALUE
cirospaciari Jul 24, 2026
80995e6
events: only override Event inspection at negative depth
cirospaciari Jul 24, 2026
4b739e4
inspect: don't print the util.inspect.custom hook back out
cirospaciari 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
7815edc
Merge remote-tracking branch 'origin/claude/callback-throw-uncaught' …
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
3f15a46
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
bb71619
Merge remote-tracking branch 'origin/claude/callback-throw-uncaught' …
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
b6b6ada
Merge remote-tracking branch 'origin/claude/callback-throw-uncaught' …
robobun Aug 4, 2026
25ea5db
Merge branch 'main' into claude/node-v26-hidden-gaps
robobun Aug 20, 2026
0fcc6db
Merge branch 'main' into claude/node-v26-hidden-gaps
robobun Aug 21, 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
12 changes: 10 additions & 2 deletions src/cares_sys/c_ares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,18 @@ impl Channel {
sock_state_cb_data: std::ptr::from_ref::<C>(this).cast_mut().cast::<c_void>(),
timeout: options.timeout.unwrap_or(-1),
tries: options.tries.unwrap_or(4),
// Node turns c-ares' answer cache off (its default max TTL is one
// hour), so a resolver in Bun must not serve stale answers either.
// https://github.com/nodejs/node/blob/v26.3.0/src/cares_wrap.cc#L897
qcache_max_ttl: 0,
..Default::default()
};

let optmask: c_int =
ARES_OPT_FLAGS | ARES_OPT_TIMEOUTMS | ARES_OPT_SOCK_STATE_CB | ARES_OPT_TRIES;
let optmask: c_int = ARES_OPT_FLAGS
| ARES_OPT_TIMEOUTMS
| ARES_OPT_SOCK_STATE_CB
| ARES_OPT_TRIES
| ARES_OPT_QUERY_CACHE;

// SAFETY: idempotent Winsock init (uv_once); c-ares creates its sockets with
// ws2_32 directly and libuv otherwise initializes Winsock lazily.
Expand Down Expand Up @@ -1817,6 +1824,7 @@ pub(crate) const ARES_OPT_FLAGS: c_int = 1 << 0;
pub(crate) const ARES_OPT_TRIES: c_int = 1 << 2;
pub(crate) const ARES_OPT_SOCK_STATE_CB: c_int = 1 << 9;
pub(crate) const ARES_OPT_TIMEOUTMS: c_int = 1 << 13;
pub(crate) const ARES_OPT_QUERY_CACHE: c_int = 1 << 21;
pub(crate) const ARES_NI_NAMEREQD: c_int = 1 << 2;
pub(crate) const ARES_NI_LOOKUPHOST: c_int = 1 << 8;
pub(crate) const ARES_NI_LOOKUPSERVICE: c_int = 1 << 9;
Expand Down
51 changes: 30 additions & 21 deletions src/js/internal-for-testing.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Hardcoded module "bun:internal-for-testing"

// If you want to test an internal API, add a binding into this file.
//
// Then at test time: import ... from "bun:internal-for-testing"
//
// In a debug build, the import is always allowed.
// It is disallowed in release builds unless run in Bun's CI.
// Add bindings for internal APIs here and `import ... from "bun:internal-for-testing"`.
// Always allowed in debug builds; in release builds only under Bun's CI.

const fmtBinding = $bindgenFn("fmt_jsc.bind.ts", "fmtString");

Expand Down Expand Up @@ -169,10 +165,9 @@ export const setSyntheticAllocationLimitForTesting: (limit: number) => number =
1,
);

// Shrink the markdown parser's block-metadata cap (in bytes) so its
// `TooManyBlocks` error is reachable without 4 GiB of input. The cap can only
// be lowered, never raised past the real limit. Returns the previous value so
// a test can restore it.
// Lower the markdown parser's block-metadata cap (bytes) so `TooManyBlocks` is
// reachable without 4 GiB of input. Can only lower, never raise past the real
// limit; returns the previous value so a test can restore it.
export const setMaxMarkdownBlockBytesForTesting: (limit: number) => number = $newRustFunction(
"MarkdownObject.rs",
"setMaxMarkdownBlockBytesForTesting",
Expand Down Expand Up @@ -323,6 +318,19 @@ function assignFunctionName(name, fn, descriptor = nodeKEmptyObject) {
});
}

// No-op emitter (Bun handles --pending-deprecation natively) but preserves `length`.
// https://github.com/nodejs/node/blob/v26.3.0/lib/internal/util.js#L204
function nodePendingDeprecate(fn) {
function deprecated(...args) {
return fn.$apply(this, args);
}
Object.defineProperty(deprecated, "length", {
__proto__: null,
...Object.getOwnPropertyDescriptor(fn, "length"),
});
return deprecated;
}

function nodeIsError(e) {
return require("node:util/types").isNativeError(e) || e instanceof Error;
}
Expand Down Expand Up @@ -448,18 +456,17 @@ function nodeGetValidStdio(stdio, sync?) {

let cachedInternalChildProcess;

// Userland access to node-internal modules for vendored node tests that
// declare `// Flags: --expose-internals` (served via the require interceptor
// in test/js/node/test/common/index.js). Static requires only — the builtin
// bundler cannot rewrite variable-path requires. Extend the map as more
// vendored tests need more internals.
// Node-internal modules for vendored tests with `// Flags: --expose-internals`
// (served via test/js/node/test/common/index.js). Static requires only — the
// builtin bundler cannot rewrite variable-path requires.
export const exposedInternals = {
"internal/streams/add-abort-signal": require("internal/streams/add-abort-signal"),
"internal/util/debuglog": require("internal/util/debuglog"),
"internal/async_context_frame": require("internal/async_context_frame"),
"internal/async_hooks": require("internal/async_hooks"),
"internal/webstreams/adapters": require("internal/webstreams_adapters"),
"internal/dgram": require("internal/dgram"),
"internal/timers": require("internal/timers"),
// Bun's real implementations, under the names node's tests import them by.
"internal/validators": require("internal/validators"),
"internal/util/inspect": require("internal/util/inspect"),
Expand All @@ -479,6 +486,7 @@ export const exposedInternals = {
assertCrypto() {},
getCIDR,
isError: nodeIsError,
pendingDeprecate: nodePendingDeprecate,
assignFunctionName,
kEnumerableProperty: Object.freeze({ __proto__: null, enumerable: true }),
kEmptyObject: nodeKEmptyObject,
Expand All @@ -502,6 +510,10 @@ export const exposedInternals = {
getValidStdio: nodeGetValidStdio,
});
},
// translatePeerCertificate lives in node:_tls_common in Bun; upstream keeps
// the implementation in internal/tls/common and re-exports it from
// _tls_common, which is where node's tests import it from.
"internal/tls/common": require("internal/tls/common"),
"internal/fs/utils": {
// Both are the REAL parsers the fs entry points use (FileSystemFlags::from_js
// and args::Rm::from_js), not JS reimplementations -- vendored tests assert
Expand All @@ -513,12 +525,9 @@ export const exposedInternals = {
// module (src/js/internal/test/binding.ts), not from here.
};

// State of a web ReadableStream/WritableStream for vendored node tests that
// read Node's `stream[kState].state` / `.storedError` (served through the
// internal/webstreams/util shim in test/js/node/test/common/index.js).
// The stream's closed promise is settled from every terminal transition, so its
// status is the state. A WritableStream mid-`erroring` still reports "writable":
// erroring is not terminal, and nothing observable distinguishes the two here.
// Web stream state for vendored node tests that read `stream[kState].state`.
// The closed promise's status is the state; a mid-`erroring` WritableStream
// reports "writable" (erroring is non-terminal, nothing observable differs).
export function getWebStreamState(stream: ReadableStream | WritableStream): {
state: string;
storedError: unknown;
Expand Down
34 changes: 29 additions & 5 deletions src/js/internal/timers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { validateNumber } = require("internal/validators");
const { validateFunction, validateNumber } = require("internal/validators");

const NumberIsFinite = Number.isFinite;

Expand All @@ -22,11 +22,35 @@ function getTimerDuration(msecs, name) {
return msecs;
}

// node's internal helper for timers that must not hold the event loop open.
// https://github.com/nodejs/node/blob/v26.3.0/lib/internal/timers.js#L370
function setUnrefTimeout(callback, after, arg1, arg2, arg3) {
validateFunction(callback, "callback");

let timer;
switch (arguments.length) {
case 1:
case 2:
timer = setTimeout(callback, after);
break;
case 3:
timer = setTimeout(callback, after, arg1);
break;
case 4:
timer = setTimeout(callback, after, arg1, arg2);
break;
default:
timer = setTimeout(callback, after, arg1, arg2, arg3);
break;
}
return timer.unref();
}

export default {
// For hiding Timeouts on other internals. A registered symbol so the node
// test harness's --expose-internals shim ("internal/timers" virtual module
// in test/js/node/test/common/index.js) can hand the same symbol to ported
// tests that inspect socket[kTimeout].
TIMEOUT_MAX,
// Registered symbol so the --expose-internals shim (test/js/node/test/common/index.js)
// hands the same symbol to ported tests that inspect socket[kTimeout].
kTimeout: Symbol.for("::buntimeout::"),
getTimerDuration,
setUnrefTimeout,
};
30 changes: 30 additions & 0 deletions src/js/internal/tls/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Translate some fields from the handle's C-friendly format into more idiomatic
// javascript object representations before passing them back to the user. Can
// be used on any cert object, but changing the name would be semver-major.
function translatePeerCertificate(c) {
if (!c) return null;

if (c.issuerCertificate != null && c.issuerCertificate !== c) {
c.issuerCertificate = translatePeerCertificate(c.issuerCertificate);
}
if (c.infoAccess != null) {
const info = c.infoAccess;
const parsed = (c.infoAccess = Object.create(null));

// XXX: More key validation?
info.replace(/([^\n:]*):([^\n]*)(?:\n|$)/g, (all, key, val) => {
if (val.charCodeAt(0) === 0x22) {
// Only used on internally created legacy cert objects; quoted values
// are always valid JSON string literals, so this never throws.
val = JSON.parse(val);
}
if (key in parsed) parsed[key].push(val);
else parsed[key] = [val];
});
}
return c;
}

export default {
translatePeerCertificate,
};
50 changes: 36 additions & 14 deletions src/js/internal/util/deprecate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ function getDeprecationWarningEmitter(code, msg, deprecated, shouldEmitWarning =
};
}

function deprecate(fn, msg, code) {
// `modifyPrototype` mirrors node's internal deprecate() parameter of the same
// name, surfaced publicly as util.deprecate(fn, msg, code, { modifyPrototype }).
// https://github.com/nodejs/node/blob/v26.3.0/lib/internal/util.js#L162
function deprecate(fn, msg, code, modifyPrototype = true) {
// Lazy-load to avoid a circular dependency.
if (code !== undefined) validateString(code, "code");

Expand All @@ -35,23 +38,42 @@ function deprecate(fn, msg, code) {
return fn.$apply(this, args);
}

// The wrapper will keep the same prototype as fn to maintain prototype chain
Object.setPrototypeOf(deprecated, fn);
const fnPrototype = fn.prototype;
if (fnPrototype) {
// Sharing fn.prototype makes instanceof work across the wrapper. Use defineProperty:
// builtin-compiled wrappers lack an own "prototype", so a plain assignment would hit
// fn's non-writable "prototype" through the prototype chain.
Object.defineProperty(deprecated, "prototype", {
// Bun compiles builtin modules such that function declarations get no own
// "prototype" property; node's wrapper is a plain function declaration, so
// give it the same default shape before applying node's prototype handling.
Object.defineProperty(deprecated, "prototype", {
__proto__: null,
value: Object.defineProperty({}, "constructor", {
__proto__: null,
value: fnPrototype,
value: deprecated,
writable: true,
enumerable: false,
configurable: true,
}),
writable: true,
enumerable: false,
configurable: false,
});

if (modifyPrototype) {
// The wrapper will keep the same prototype as fn to maintain prototype chain
Object.setPrototypeOf(deprecated, fn);
const fnPrototype = fn.prototype;
if (fnPrototype) {
// Sharing fn.prototype makes instanceof work across the wrapper. Use defineProperty:
// builtin-compiled wrappers lack an own "prototype", so a plain assignment would hit
// fn's non-writable "prototype" through the prototype chain.
Object.defineProperty(deprecated, "prototype", {
__proto__: null,
value: fnPrototype,
writable: true,
});
}
Object.defineProperty(deprecated, "length", {
__proto__: null,
...Object.getOwnPropertyDescriptor(fn, "length"),
});
}
Object.defineProperty(deprecated, "length", {
__proto__: null,
...Object.getOwnPropertyDescriptor(fn, "length"),
});
return deprecated;
}

Expand Down
33 changes: 2 additions & 31 deletions src/js/node/_tls_common.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
// Hardcoded module "node:_tls_common"
// Deprecated shim mirroring node's lib/_tls_common.js: re-exports the real
// implementations and warns on load.
// Deprecated shim: re-exports the real impls and warns on load.
// https://github.com/nodejs/node/blob/v26.3.0/lib/_tls_common.js
const { SecureContext, createSecureContext } = require("node:tls");

process.emitWarning("The _tls_common module is deprecated. Use `node:tls` instead.", "DeprecationWarning", "DEP0192");

// Translate some fields from the handle's C-friendly format into more idiomatic
// javascript object representations before passing them back to the user. Can
// be used on any cert object, but changing the name would be semver-major.
function translatePeerCertificate(c) {
if (!c) return null;

if (c.issuerCertificate != null && c.issuerCertificate !== c) {
c.issuerCertificate = translatePeerCertificate(c.issuerCertificate);
}
if (c.infoAccess != null) {
const info = c.infoAccess;
const parsed = (c.infoAccess = Object.create(null));

// XXX: More key validation?
info.replace(/([^\n:]*):([^\n]*)(?:\n|$)/g, (all, key, val) => {
if (val.charCodeAt(0) === 0x22) {
// The translatePeerCertificate function is only
// used on internally created legacy certificate
// objects, and any value that contains a quote
// will always be a valid JSON string literal,
// so this should never throw.
val = JSON.parse(val);
}
if (key in parsed) parsed[key].push(val);
else parsed[key] = [val];
});
}
return c;
}
const { translatePeerCertificate } = require("internal/tls/common");

export default {
SecureContext,
Expand Down
Loading
Loading