Commit af06a65
committed
fix: subscribe to governance stores before checking sync status
Bugbot flagged a permanent-skip loop in Governance.sync (both v1 and v2):
getDataLayerStoreSyncStatus returns false for a store the DataLayer node
has no record of, isDlStoreSynced(undefined) is false, sync() early-exits,
and because sync() was the only place that called
subscribeToStoreOnDataLayer (via getSubscribedStoreData), the store never
got subscribed and the skip repeated forever on every scheduled run.
Mirror the subscribe-first pattern already used in
OrganizationsV2.reconcileOrganization: subscribe first (idempotent), then
check sync status. Applied to both the governance body store and the
versioned-governance store in both v1 and v2 models.
subscribeToStoreOnDataLayer returns false on the common
datalayer-unreachable / RPC-failure paths (it does not throw), so guard
on both a falsy return and thrown exceptions. Without the falsy-return
check, the dominant failure mode would slip past the try/catch and the
subsequent status-check skip would fire with a misleading log.
Adds tests/v2/integration/governance-sync-subscribe-first.spec.js
covering five branches of GovernanceV2.sync:
- subscribeToStoreOnDataLayer runs before getDataLayerStoreSyncStatus on
the body store
- sync() returns cleanly when the body-store subscribe throws
- sync() returns cleanly when the body-store subscribe returns falsy
- sync() subscribes to the versioned store before its status check (call
order: body-subscribe -> body-status -> body-fetch -> versioned-subscribe
-> versioned-status), and does not upsert when the versioned store is
unsynced
- sync() returns cleanly when the versioned-store subscribe returns falsy
The v1 model captures USE_SIMULATOR at module import time so the same
test pattern cannot reach its production path; the v1 change is
structurally identical to v2 and is reviewed by code reading.1 parent 6e76235 commit af06a65
3 files changed
Lines changed: 413 additions & 0 deletions
File tree
- src/models
- governance
- v2
- tests/v2/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
178 | 200 | | |
179 | 201 | | |
180 | 202 | | |
| |||
224 | 246 | | |
225 | 247 | | |
226 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
227 | 267 | | |
228 | 268 | | |
229 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
457 | 479 | | |
458 | 480 | | |
459 | 481 | | |
| |||
505 | 527 | | |
506 | 528 | | |
507 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
508 | 548 | | |
509 | 549 | | |
510 | 550 | | |
| |||
0 commit comments