Checking or converting a dyn value whose objects or arrays refer back to
each other against a recursive interface (`raw.next = raw; raw as Node`)
recursed without end and overflowed the stack. Matchers and builders of
record and array types that reach themselves now track the dyn values
they visit:
- a matcher answers true for a (value, type) pair it is already checking
further up the stack, so the outer check decides;
- a builder records the record or array it allocated for a dyn value
before converting its members, and a later visit of the same value in
the conversion answers it, so `n.next === n` holds after the cast and a
value reached twice converts once.
Only values with more than one reference are tracked, since a value
reached twice has at least two; the reference a member read holds is not
counted. Capsules materialized during a conversion keep their first view,
so a nested visit cannot refresh a view an outer visit is reading, and
getters and proxy traps that a member read calls run outside the visit. The
cycle analysis treats record shapes that reach themselves and are targets
of a dynCheck as mutable, so the cyclic records a conversion builds are
collected.
A released region that something outside still refers to is kept, and
SCRIPTC_REGION_STATS only said how many references the walk could not
explain. In a build with --optimization=dev (or --sanitize), setting
SCRIPTC_REGION_DEBUG=1 (or a larger number, the line limit) makes each
attempt that keeps a region also print what keeps it:
- per chunk, the references to its objects that the walk did not find
(from variables, other regions or objects it does not walk), with the
classes the chunk holds, since counts are kept per chunk;
- each ordinary object the region owns that is referenced from outside,
named by the region class and field it was reached through, with its
reference count and the references the walk found.
The emitted region class descriptors gain the names of the fields their
visits report, in visit order. Debug walks give every owned object an
entry, so that each one records where the walk first reached it. The
bookkeeping is compiled only into unoptimized and RC-audit runtimes:
compiled in, it made the release walk 6.5% slower even with the variable
unset. Optimized runtimes walk as before and, when the variable is set,
say once that the reports need a dev build. Retains, releases and
allocation are unchanged.
Adds corpus program 5703.
Atomics.load, store, exchange, compareExchange, add, sub, and, or and xor
on an integer typed array compile to one sequentially consistent LLVM
atomic instruction on the element. An index that is not an integer in
range takes the runtime operation, which applies ToIndex and raises its
errors.
The fs error-first callbacks (readFile, writeFile, stat, access, mkdir and
the other callback forms that complete synchronously) and fs.exists
delivered their callback through a zero-delay timer. Timers have a 1 ms
floor, so every callback waited about 1 ms: 5000 sequential readFile
callbacks took 5.5 s, where Node takes about 0.35 s.
The callbacks now go on a FIFO queue that the event loop drains like the
worker-pool completions: one callback per checkpoint, with nextTicks and
microtasks drained between callbacks. A turn delivers the callbacks that
were queued when its timers ran, as libuv's poll phase does, so a
callback that queues another leaves room for timers and immediates.
Corpus 5555 covers the order against the synchronous code and its
microtasks, and timers and immediates during a chain of 2000 callbacks.
node:test's mock.fn(original[, implementation]) and t.mock.fn compile.
A Mock<F> is the function-with-properties record { %call, mock }: the
callable is a wrapper closure that shares the mock context with the mock
field. The context records each call's arguments, result, error and this,
and keeps the current implementation, the original and the one-time
implementations by call index. fn.mock supports, as in Node 24.22:
- calls, read as a copy of the log;
- callCount();
- mockImplementation(fn);
- mockImplementationOnce(fn[, onCall]), for the next call by default, a
later registration for the same index replacing the earlier one;
- resetCalls();
- restore(), which brings back the original.
A throwing implementation records the error and rethrows it. Functions
with fixed parameters or a single rest array parameter are supported; a
union return type needs an undefined arm. mock.fn() without an original,
mock.method, the tracker's reset and restoreAll, and t.mock.method are
refused with SC2020.
The node:test fixture mock-fn compares the behavior with Node, and
tests/diagnostics/mock-fences.ts covers the refusals.
Atomics operations on 8-, 16- and 32-bit integer arrays are sequentially
consistent atomic instructions on the element, and no longer take the
process-wide shared-memory lock. Other reads and writes of shared storage
are relaxed atomic accesses: element reads and writes access the element,
and copies, fills, conversions, searches and sorts read shared bytes into
a private copy and write back only the range they change, so concurrent
accesses to the same bytes are free of data races. Non-shared storage
keeps its plain memory accesses. Atomics.wait and Atomics.notify queue
waiters in buckets chosen by location, each with its own lock and
condition variable, so waiting threads no longer serialize other Atomics.
Atomics.store answers +0 for a value that truncates to -0, as Node does.
The shared storage runtime test also runs under ThreadSanitizer.
self-hosting-native-frontend.test.ts was one test of 577 s (plain) and 607 s
(sanitized) in the cost table, and 748 s on san 1/20 in run 38835202089; once
the other long files were spread, it alone bounded the Linux test lane. It
builds the compiler frontend into a native executable, then checks 17 corpus
programs and four other cases with it. Locally the build took about 189 s and
the checks 297 s (14-20 s per program).
The build and the checks move to tests/harness/native-frontend.ts without
changes to what they check; useNativeFrontend builds the executable in a
beforeAll of the calling suite. self-hosting-native-frontend.test.ts,
-programs.test.ts and -checks.test.ts each build once and run programs 1-6,
7-12, and 13-17 plus the four other checks, each check as its own test. The
diagnostics, library contract and FFI checks use project directories of their
own instead of rewriting one shared main.ts.
scripts/ci-test-costs.json replaces the old file's entry with estimates for
the three files (the build share of its measured cost plus each file's share of
the checks); the next refresh measures them, since vitest's file time includes
beforeAll. The largest side-queue share per shard at 20 shards goes from 580 to
367 s (plain) and from 608 to 432 s (sanitized), for two more builds per flavor.
In a program that constructs a LifetimeRegion, the retain and release of
every ProgramLifetime class count references in the chunk that holds the
instance, once the process has created a region. Speed builds inline those
bodies into every use of an instance. A program that references
LifetimeRegion but never creates a region still carried the counting path
inline at every use, and its walks over ProgramLifetime graphs ran about
10% slower than the same program without the reference.
The flag test that skips counting is now marked likely, so the counting
path is laid out away from the callers' hot code. Programs that create
regions take the same path as before.
node:test changes, matching Node 24.22:
- t.before, t.after, t.beforeEach and t.afterEach lower. t.before runs
when it is called; a throw fails the test and the subtests that follow,
which skip their body and beforeEach hooks and run their afterEach hooks.
t.beforeEach and t.afterEach wrap every descendant subtest. t.after runs
after the test's afterEach chain, also when the body throws, and a throw
fails the test.
- t.plan(count) counts the test's t.assert calls and subtests. A mismatch
fails the test with Node's "plan expected N assertions but received M"
string, unless an assertion failed first.
- t.fullName joins the names from the outermost suite or test with " > ".
- Tests and suites under a todo suite or test are todo, with a bare TODO
directive, unless they are skipped or carry their own todo message. A
todo suite reports its directive.
- describe.only, suite.only and { only: true } on a suite mark it. At each
level, when a child is marked or contains a marked test or suite, only
those children run.
- The failing-tests section lists failures in completion order, so
subtests come before the test that ran them, and prints thrown strings
quoted, as Node inspects them.
The fixtures ctx-hooks, ctx-plan, todo-suites, suite-variants,
only-nested and thrown-values compare the reporter output and exit code
with Node.
npm-static.test.ts ran whole on one shard as an isolated suite: 406 s plain and
519 s sanitized in the cost table, and 672 s on san 2/20 in run 38835202089,
the second-longest job of that run.
skipUnownedTest (tests/harness/shard.ts), called from the suite's beforeEach,
balances the suite's tests across the shards of SCRIPTC_TEST_SHARD by their
measured milliseconds (tests/harness/npm-static-costs.json; an unmeasured test
weighs as much as the median) and skips the tests this shard does not own.
Repeated test.each titles get an occurrence suffix as their key. Without a
shard spec every test runs.
The CI plan runs the suite on every shard in its own vitest process
(caseShardedSideFiles) instead of on one owner. At 20 shards the largest
shares are 113 and 106 s plain and 181 and 137 s sanitized (the two published
Effect generator tests), and about 10 s elsewhere, plus about 11 s per shard to
collect the file. scripts/ci-test-costs.mjs also refreshes the per-test table
and drops side-queue files that no longer run whole.
The sequencer that started three.test.ts first made vitest queue the corpus
files in a different order. In run 38840458162 llvm-differential.test.ts then
started only after differential.test.ts had finished, on all 20 sanitized
Linux shards (none of 20 in run 38835202089, before the sequencer), and the
sanitized corpus process took 581 s at the median instead of 458 s. A local
run with a reporter that logs when each file is queued shows the same order:
without the sequencer the two differential files are queued first and run
side by side.
This removes the sequencer from vitest.config.ts. Placing the longest
side-queue files from the last shard is unchanged.
The release walk gave every ordinary object it reached an entry in an
open-addressing table, to count the references it found to it and the
edges between entries. A region of 1.2M objects that each own an array
spent most of its 200 ms walk inserting into that table.
An object with a single reference, found from one of the region's own
objects or from an object walked like them, has no other referrer, so it
can never be referenced from outside the region. It now gets no entry and
no edges and is walked like the region's own objects, its references into
the region counted as explained. RC-audit builds still enter these objects
and stop when the walk reaches one twice.
Arrays and maps also resolve their elements' release entry point once per
container instead of once per element.
Every region creation, release and pressure retry walked every condemned
region again. A released region that something still refers to was
re-walked on each of them, two or three times per build in a watch loop,
and each walk visits every object of the region.
An attempt that keeps a region now records the references counted to it.
Retries at creation, release and region entry attempt a kept region again
only when that count has changed, or once the thread has allocated 8 MiB
(or the region's size, if larger) in regions since the attempt. That
volume doubles after each attempt that finds the count unchanged, up to
64 times. The volume covers references from ordinary objects the walk
reaches, which can go away without changing the count. The schedule is
per region, so a region that another region's release unblocks is
attempted at once, and the full cycle collection before an attempt runs
only when some region is due.
Adds the region-builds runtime benchmark and a region test for the
schedule.
publish() used to remove each published object from this thread's
cycle-collector candidate buffers after the walk, which loaded every
object's collector header a second time. On graphs larger than the
cache that second pass took about a third of the publish.
scr_pub_mark now takes a buffered object out of its buffer when it marks
it, while the header is in cache: the slot is cleared and its index
recorded. When the publish ends, scr_cyc_pub_fill closes the empty slots
with entries from the ends of the buffers. A refused publish puts each
taken object back in its slot first. After the walk, the log is read only
for dyn containers, the RC audit and LeakSanitizer.
The emitted walkers test null and immortal references (parent links,
values published before) before calling scr_pub_push, and the string
walker checks for ASCII 32 bytes at a time.
Adds the published-graphs runtime benchmark, a cycle collector test for
the take, restore and fill hooks, and corpus program 5702.
The util.format %f branch for boolean and unit arguments discarded the
lowered value and lowered the argument node again as a statement, so
anything lowering builds for the argument (lifted array helpers,
closures) was built twice, one copy dead. It now evaluates the value it
already lowered as a statement, and drops it when evaluating it has no
observable effect.
The same branch now also covers void calls and null | undefined unions,
which Node formats as NaN like undefined and null; they were refused.
Since pushes to main run to completion, each ran the complete suite on macOS:
20 test jobs and about 350 macOS job-minutes per push (run 38831529977), which
at about four pushes an hour exceeded the repository's macOS runners. On
2026-10-16 at 02:40 UTC 41 macOS jobs were running, 95 were queued (the oldest
for 35 minutes), and main runs took over an hour.
Pushes to main now run the darwin suite on macOS, as pull requests do: 6 jobs
and about 100 minutes (run 38835202089). The nightly schedule still runs the
complete suite, and a manual run (workflow_dispatch) with macos_full set runs
it on demand, for example on a release candidate commit. Manual runs get a
concurrency group of their own, so they neither cancel nor wait for the push
run of the same commit. The policy test evaluates the macOS matrix expressions
for each event.
pipeline() accepts a source function (an async generator function called
with { signal }) and a destination async function, following
pipeline.js: the destination's promise value resolves the
stream/promises form and reaches the callback's second argument, and
pipeline() answers a PassThrough for it. A rejected destination destroys
that PassThrough with the reason and fails the pipeline.
Stages may take the { signal } argument: the pipeline creates its own
AbortController when one does, and aborts it when the pipeline finishes
or fails, as finishImpl does. Stage functions take the source and
{ signal } through the closure ABI, and the PassThrough and the value
are released with the pipeline.
The stream unit now links the emitter unit whenever it links, so a
pipeline of functions builds without constructing a stream. An async
generator destination and reading the PassThrough a function destination
returns are refused at compile time.
Encoding an array key added each element's size to a running length
with unchecked arithmetic, and wrote into a fixed stack buffer whenever
the sum fit. A sparse array with a large length (2^29 elements or more)
wrapped the sum on 32-bit targets, so the write landed before the buffer;
on every target the encoder also visited every index of such an array.
Array keys now have at most 65536 elements, and their encoding at most
2^31 - 1 bytes. The size is computed first with sums that cannot wrap,
the buffer is sized to it, and keys over either limit make the lookup or
insert throw a TypeError before anything is read or written. The Node.js
implementation throws the same TypeError for keys of more than 65536
elements. Sparse elements are walked in one pass in index order, and the
index growth computation checks its size arithmetic too.