Skip to content

test: reproduce late map subscription sync gaps - #1421

Merged
amark merged 1 commit into
amark:masterfrom
tmsteph:test/map-live-sync-reproduction
Aug 1, 2026
Merged

test: reproduce late map subscription sync gaps#1421
amark merged 1 commit into
amark:masterfrom
tmsteph:test/map-live-sync-reproduction

Conversation

@tmsteph

@tmsteph tmsteph commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a PANIC regression test for an intermittent synchronization gap when a browser subscribes to an existing dynamic index with .map().on() after another peer has populated it through a relay.

The test deliberately does not reload Bob or issue a second explicit request. It expects every indexed record to arrive from the initial subscription.

Scenario

  1. Start one Node relay.
  2. Alice connects and writes item records plus dynamic index fields.
  3. Bob initializes only after Alice's writes are acknowledged.
  4. Bob subscribes to the index using .map().on().
  5. Assert that Bob discovers every indexed record within 30 seconds.

Reproduction results

Using the repository's current master build:

  • 100 records: passed 5/5 runs
  • 200 records: passed
  • 250 records: failed in repeated runs; Bob received 86/250 once and 0/250 once
  • 1,000 records: Alice's write acknowledgements timed out after two minutes and Bob received 0/1,000

For comparison, the npm/CDN release used by the application where this behavior was first observed (0.2020.1241) passed 250/250 twice in approximately 5.6–6.8 seconds.

These results suggest the behavior is load-sensitive and may differ by build/version. This draft contributes the reproduction harness first; it does not propose a core fix yet.

Running the test

npx mocha test/panic/map-late-subscribe.js

The item count and browser/GUN paths can be overridden:

PANIC_ITEMS=250 \
PANIC_CHROMIUM_EXECUTABLE=/path/to/chromium \
npx mocha test/panic/map-late-subscribe.js

The test also accepts PANIC_GUN_ROOT and PANIC_GUN_BROWSER for cross-version comparisons.

Related: #1406, #1404, #1316, #1330.

@tmsteph
tmsteph marked this pull request as ready for review July 27, 2026 03:05
@amark

amark commented Aug 1, 2026

Copy link
Copy Markdown
Owner

@tmsteph you're a hero (also, please DM / text me cuz GitHub doesn't notify me), flying back from few international travels now.

With a replicable failure, I'm hoping an AI can pinpoint in a trace/log the gap. My hunch is my special CPU breathing loops (probably not the poll/turn etc. utility itself) where it's queuing/dequeuing a get ack / reply and maybe the queue gets mutated while it breathes & it then misses it.

@amark
amark merged commit 5522275 into amark:master Aug 1, 2026
3 checks passed
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.

2 participants