Skip to content

Conversation

@grgbkr
Copy link
Contributor

@grgbkr grgbkr commented Jan 9, 2026

See: https://bugs.rocicorp.dev/p/zero/issue/246592

npm run test -- --silent=false 'client/zero.test.ts'

@grgbkr grgbkr requested a review from 0xcadams January 9, 2026 17:52
@vercel
Copy link

vercel bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
replicache-docs Ready Ready Preview, Comment Jan 14, 2026 6:00pm
zbugs Ready Ready Preview, Comment Jan 14, 2026 6:00pm

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

🐰 Bencher Report

Branchgrgbkr/repro-run-loop-race
TestbedLinux
Click to view all benchmark results
BenchmarkFile SizeBenchmark Result
kilobytes (KB)
(Result Δ%)
Upper Boundary
kilobytes (KB)
(Limit %)
zero-package.tgz📈 view plot
🚷 view threshold
1,783.56 KB
(+0.02%)Baseline: 1,783.22 KB
1,818.88 KB
(98.06%)
zero.js📈 view plot
🚷 view threshold
242.99 KB
(+0.12%)Baseline: 242.70 KB
247.55 KB
(98.16%)
zero.js.br📈 view plot
🚷 view threshold
66.66 KB
(+0.06%)Baseline: 66.62 KB
67.96 KB
(98.10%)
🐰 View full continuous benchmarking report in Bencher

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

🐰 Bencher Report

Branchgrgbkr/repro-run-loop-race
Testbedself-hosted
Click to view all benchmark results
BenchmarkThroughputBenchmark Result
operations / second (ops/s)
(Result Δ%)
Lower Boundary
operations / second (ops/s)
(Limit %)
1 exists: track.exists(album)📈 view plot
🚷 view threshold
12,947.94 ops/s
(-8.76%)Baseline: 14,190.52 ops/s
12,021.82 ops/s
(92.85%)
10 exists (AND)📈 view plot
🚷 view threshold
189,287.08 ops/s
(-9.19%)Baseline: 208,434.51 ops/s
172,617.65 ops/s
(91.19%)
10 exists (OR)📈 view plot
🚷 view threshold
3,830.08 ops/s
(-5.90%)Baseline: 4,070.28 ops/s
3,455.86 ops/s
(90.23%)
12 exists (AND)📈 view plot
🚷 view threshold
169,708.56 ops/s
(-7.79%)Baseline: 184,036.79 ops/s
152,014.30 ops/s
(89.57%)
12 exists (OR)📈 view plot
🚷 view threshold
3,276.80 ops/s
(-5.29%)Baseline: 3,459.80 ops/s
2,925.92 ops/s
(89.29%)
12 level nesting📈 view plot
🚷 view threshold
2,839.47 ops/s
(-6.04%)Baseline: 3,022.03 ops/s
2,578.30 ops/s
(90.80%)
2 exists (AND): track.exists(album).exists(genre)📈 view plot
🚷 view threshold
4,900.90 ops/s
(-8.19%)Baseline: 5,338.20 ops/s
4,544.06 ops/s
(92.72%)
3 exists (AND)📈 view plot
🚷 view threshold
1,903.00 ops/s
(-8.29%)Baseline: 2,074.95 ops/s
1,763.47 ops/s
(92.67%)
3 exists (OR)📈 view plot
🚷 view threshold
949.14 ops/s
(-8.75%)Baseline: 1,040.20 ops/s
883.09 ops/s
(93.04%)
5 exists (AND)📈 view plot
🚷 view threshold
299.73 ops/s
(-8.39%)Baseline: 327.17 ops/s
278.95 ops/s
(93.07%)
5 exists (OR)📈 view plot
🚷 view threshold
156.57 ops/s
(-9.16%)Baseline: 172.35 ops/s
145.90 ops/s
(93.19%)
Nested 2 levels: track > album > artist📈 view plot
🚷 view threshold
4,198.80 ops/s
(-9.51%)Baseline: 4,640.18 ops/s
3,933.11 ops/s
(93.67%)
Nested 4 levels: playlist > tracks > album > artist📈 view plot
🚷 view threshold
724.69 ops/s
(-5.08%)Baseline: 763.44 ops/s
655.50 ops/s
(90.45%)
Nested with filters: track > album > artist (filtered)📈 view plot
🚷 view threshold
3,687.06 ops/s
(-4.68%)Baseline: 3,868.09 ops/s
3,312.19 ops/s
(89.83%)
planned: playlist.exists(tracks)📈 view plot
🚷 view threshold
588.41 ops/s
(-7.45%)Baseline: 635.77 ops/s
559.98 ops/s
(95.17%)
planned: track.exists(album) OR exists(genre)📈 view plot
🚷 view threshold
150.66 ops/s
(-10.41%)Baseline: 168.18 ops/s
150.47 ops/s
(99.87%)
planned: track.exists(album) where title="Big Ones"📈 view plot
🚷 view threshold
7,018.98 ops/s
(-9.45%)Baseline: 7,751.63 ops/s
6,816.76 ops/s
(97.12%)
planned: track.exists(album).exists(genre)📈 view plot
🚷 view threshold
36.08 ops/s
(-10.50%)Baseline: 40.31 ops/s
35.07 ops/s
(97.21%)
planned: track.exists(album).exists(genre) with filters📈 view plot
🚷 view threshold
4,876.00 ops/s
(-10.97%)Baseline: 5,476.80 ops/s
4,775.49 ops/s
(97.94%)
planned: track.exists(playlists)📈 view plot
🚷 view threshold
3.73 ops/s
(-8.95%)Baseline: 4.10 ops/s
3.61 ops/s
(96.57%)
unplanned: playlist.exists(tracks)📈 view plot
🚷 view threshold
562.23 ops/s
(-9.13%)Baseline: 618.74 ops/s
543.29 ops/s
(96.63%)
unplanned: track.exists(album) OR exists(genre)📈 view plot
🚷 view threshold
41.90 ops/s
(-8.72%)Baseline: 45.91 ops/s
39.68 ops/s
(94.71%)
unplanned: track.exists(album) where title="Big Ones"📈 view plot
🚷 view threshold
52.13 ops/s
(-9.29%)Baseline: 57.47 ops/s
50.27 ops/s
(96.43%)
unplanned: track.exists(album).exists(genre)📈 view plot
🚷 view threshold
36.36 ops/s
(-9.36%)Baseline: 40.11 ops/s
35.03 ops/s
(96.36%)
unplanned: track.exists(album).exists(genre) with filters📈 view plot
🚷 view threshold
51.53 ops/s
(-8.40%)Baseline: 56.26 ops/s
49.94 ops/s
(96.90%)
unplanned: track.exists(playlists)📈 view plot
🚷 view threshold
3.72 ops/s
(-9.29%)Baseline: 4.10 ops/s
3.60 ops/s
(96.78%)
zpg: all playlists📈 view plot
🚷 view threshold
5.35 ops/s
(-6.41%)Baseline: 5.72 ops/s
5.23 ops/s
(97.62%)
zql: all playlists📈 view plot
🚷 view threshold
7.03 ops/s
(-10.44%)Baseline: 7.85 ops/s
6.51 ops/s
(92.65%)
zql: edit for limited query, inside the bound📈 view plot
🚷 view threshold
198,871.62 ops/s
(-6.88%)Baseline: 213,572.65 ops/s
183,934.06 ops/s
(92.49%)
zql: edit for limited query, outside the bound📈 view plot
🚷 view threshold
198,485.09 ops/s
(-10.12%)Baseline: 220,841.29 ops/s
177,446.85 ops/s
(89.40%)
zql: push into limited query, inside the bound📈 view plot
🚷 view threshold
97,085.21 ops/s
(-11.25%)Baseline: 109,388.02 ops/s
93,718.56 ops/s
(96.53%)
zql: push into limited query, outside the bound📈 view plot
🚷 view threshold
374,661.41 ops/s
(-6.13%)Baseline: 399,135.93 ops/s
318,802.32 ops/s
(85.09%)
zql: push into unlimited query📈 view plot
🚷 view threshold
296,562.84 ops/s
(-10.55%)Baseline: 331,541.86 ops/s
278,043.02 ops/s
(93.76%)
zqlite: all playlists📈 view plot
🚷 view threshold
1.60 ops/s
(-11.66%)Baseline: 1.81 ops/s
1.52 ops/s
(95.10%)
zqlite: edit for limited query, inside the bound📈 view plot
🚷 view threshold
68,953.29 ops/s
(-10.32%)Baseline: 76,888.84 ops/s
62,467.81 ops/s
(90.59%)
zqlite: edit for limited query, outside the bound📈 view plot
🚷 view threshold
66,320.95 ops/s
(-14.18%)Baseline: 77,278.99 ops/s
61,110.93 ops/s
(92.14%)
zqlite: push into limited query, inside the bound📈 view plot
🚷 view threshold
3,862.74 ops/s
(-5.27%)Baseline: 4,077.76 ops/s
3,766.26 ops/s
(97.50%)
zqlite: push into limited query, outside the bound📈 view plot
🚷 view threshold
80,917.97 ops/s
(-8.85%)Baseline: 88,775.81 ops/s
77,688.58 ops/s
(96.01%)
zqlite: push into unlimited query📈 view plot
🚷 view threshold
107,595.50 ops/s
(-14.13%)Baseline: 125,300.37 ops/s
106,792.51 ops/s
(99.25%)
🐰 View full continuous benchmarking report in Bencher

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

🐰 Bencher Report

Branchgrgbkr/repro-run-loop-race
Testbedself-hosted
Click to view all benchmark results
BenchmarkThroughputBenchmark Result
operations / second (ops/s)
(Result Δ%)
Lower Boundary
operations / second (ops/s)
(Limit %)
src/client/custom.bench.ts > big schema📈 view plot
🚷 view threshold
124,820.00 ops/s
(-47.46%)Baseline: 237,556.93 ops/s
-338,715.50 ops/s
(-271.36%)
src/client/zero.bench.ts > basics > All 1000 rows x 10 columns (numbers)📈 view plot
🚷 view threshold
2,341.10 ops/s
(-6.35%)Baseline: 2,499.76 ops/s
2,137.50 ops/s
(91.30%)
src/client/zero.bench.ts > pk compare > pk = N📈 view plot
🚷 view threshold
59,706.00 ops/s
(-7.76%)Baseline: 64,729.23 ops/s
56,007.53 ops/s
(93.81%)
src/client/zero.bench.ts > with filter > Lower rows 500 x 10 columns (numbers)📈 view plot
🚷 view threshold
3,573.29 ops/s
(-6.60%)Baseline: 3,825.64 ops/s
3,341.63 ops/s
(93.52%)
🐰 View full continuous benchmarking report in Bencher

@0xcadams 0xcadams force-pushed the grgbkr/repro-run-loop-race branch from efb33f2 to 057da15 Compare January 12, 2026 18:30
@0xcadams 0xcadams marked this pull request as ready for review January 12, 2026 19:47
@0xcadams 0xcadams changed the title repro race condition in zero run-loop fix: race condition in zero run-loop Jan 12, 2026
@0xcadams
Copy link
Member

@grgbkr this should be fixed now. Could you give it a review when you get a chance?

@0xcadams
Copy link
Member

OK I am merging this, feel free to leave comments @grgbkr if you get a chance to review

@grgbkr
Copy link
Contributor Author

grgbkr commented Jan 14, 2026

@0xcadams I'm not quite following how the fix works. Can you update the PR description to describe how the fix works? Thanks!

@grgbkr
Copy link
Contributor Author

grgbkr commented Jan 14, 2026

@0xcadams as part of this change can you also cleanup the calls to

await tickAFewTimes(vi, RUN_LOOP_INTERVAL_MS);
and
await vi.advanceTimersByTimeAsync(0);

in zero.test.ts around connection state transitions.

@0xcadams 0xcadams disabled auto-merge January 14, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants