You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[lexical-y] Bug: DisposeMemory heap threshold fails under 16-worker parallel load on main #9658
packages/lexical-y/src/__tests__/unit/DisposeMemory.test.ts ("40 editors bound, edited and disposed in a synchronous loop hold no document") fails intermittently on main when the unit suite runs with high parallelism, because it measures process.memoryUsage().heapUsed before and after the loop and asserts the delta is under 8 MB. The heap it reads is the worker's whole heap, so garbage that other code in the same worker produces between the two reads is counted.
Measured on main 4c04461b, full unit suite (vitest --run --project unit --maxWorkers=16) on a loaded host, 10 runs. Each run measured twice (the test itself and an identical copy that logs its delta):
configuration
over 8 MB
deltas
alone (--maxWorkers=1, only this file), 10 runs
0 / 10
3.07 to 3.12 MB
full suite, --maxWorkers=10, 10 runs
0 / 10
-5.0 to 2.9 MB
full suite, --maxWorkers=16, 10 runs
6 / 20 measurements (the test itself failed in 4 of the 10 runs)
Branches built on main show the same rate under the same condition (1 / 20 and 2 / 20 in two of them), so this is the test's sensitivity to load, not a regression in a change.
The property the test protects (a binding stopped inside a synchronous loop does not keep its editor and document alive through a scheduled microtask) is real; only the measurement is noisy.
Possible fixes, any of:
run the file in its own worker / a serial pool (poolMatchGlobs or a separate project with maxWorkers: 1), so nothing else allocates in that heap;
measure retention directly instead of a heap delta: keep a WeakRef (or register a FinalizationRegistry callback) for each editor and document created in the loop, force gc() after the loop, and assert that they were collected;
if a heap delta stays, take the minimum of several gc'd readings and leave more headroom.
Test plan
Before
pnpm exec vitest --run --project unit --maxWorkers=16 # on a loaded host, repeated
FAIL unit packages/lexical-y/src/__tests__/unit/DisposeMemory.test.ts > 40 editors bound, edited and disposed in a synchronous loop hold no document
AssertionError: expected 13649192 to be less than 8000000
(4 of 10 runs; alone it passes 10 of 10 at about 3.1 MB.)
Activity