Commit 8550c8f
committed
fix: persist v1/v2 org-creation progress incrementally and fix v2 helper endpoint
The V1 and V2 _createStoresInParallel functions only persisted store-id
state via a single saveCreationState call after Promise.all resolved. A
slow 4th store (e.g. blocked on per-store waitForNewStoreToBeConfirmed
polling) hid the other 3 successful creations from
GET /v{1,2}/organizations/creation-status, which made the live-api
"stuck state" detector trigger at 5 minutes even though the server was
actively making progress.
Introduce createIncrementalStateWriter (mutex-protected, snapshot-then-
persist) so each successful store creation immediately updates the
persisted state. A successful on-chain createDataLayerStoreWithRetry
followed by a transient saveCreationState failure is no longer treated
as a creation failure: the storeId is retained in the per-store result
and reconciled in a final save before _createStoresInParallel returns,
so we never throw "Failed to create stores" for an actually-created
on-chain store and we never leak it on retry.
Two test-side fixes accompany the server change:
1. Bump stuckStateThresholdMs from 5 min to 10 min in V1/V2
waitForOrganizationReady. Realistic V1/V2 org creation can take 5+
min when a transient wallet desync triggers 30s retry backoffs and
per-store blockchain-confirmation polling. With the new incremental
persistence the threshold only fires when no store has progressed
for the full window.
2. Fix waitForV2OrganizationReady to poll
/v2/organizations/creation-status (returns {state, stores,
inProgress, error}) instead of /v2/organizations/status (which is
homeOrgSyncStatus, returning {ready, status, success}). The wrong
endpoint silently disabled the FAILED-fast-fail and stuck-state
detector entirely for V2.
Adds focused unit tests for the writer's incremental save, concurrent
Promise.all behavior, V1 Meta-model variant, and rollback on persist
failure.1 parent 9e7897c commit 8550c8f
5 files changed
Lines changed: 299 additions & 24 deletions
File tree
- src
- models
- organizations
- v2
- utils
- tests/v2
- integration
- live-api/helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
497 | 498 | | |
498 | 499 | | |
499 | 500 | | |
500 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
501 | 513 | | |
502 | 514 | | |
503 | 515 | | |
504 | | - | |
| 516 | + | |
505 | 517 | | |
506 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
507 | 529 | | |
508 | 530 | | |
509 | 531 | | |
510 | 532 | | |
511 | | - | |
| 533 | + | |
512 | 534 | | |
513 | 535 | | |
514 | 536 | | |
| |||
517 | 539 | | |
518 | 540 | | |
519 | 541 | | |
520 | | - | |
| 542 | + | |
521 | 543 | | |
522 | 544 | | |
523 | 545 | | |
| |||
526 | 548 | | |
527 | 549 | | |
528 | 550 | | |
529 | | - | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
530 | 557 | | |
531 | | - | |
| 558 | + | |
532 | 559 | | |
| 560 | + | |
533 | 561 | | |
534 | 562 | | |
535 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
536 | 566 | | |
537 | 567 | | |
538 | 568 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
523 | 524 | | |
524 | 525 | | |
525 | 526 | | |
526 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
527 | 539 | | |
528 | 540 | | |
529 | 541 | | |
530 | | - | |
| 542 | + | |
531 | 543 | | |
532 | | - | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
533 | 555 | | |
534 | 556 | | |
535 | 557 | | |
536 | 558 | | |
537 | | - | |
| 559 | + | |
538 | 560 | | |
539 | 561 | | |
540 | 562 | | |
| |||
543 | 565 | | |
544 | 566 | | |
545 | 567 | | |
546 | | - | |
| 568 | + | |
547 | 569 | | |
548 | 570 | | |
549 | 571 | | |
| |||
552 | 574 | | |
553 | 575 | | |
554 | 576 | | |
555 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
556 | 583 | | |
557 | | - | |
| 584 | + | |
558 | 585 | | |
| 586 | + | |
559 | 587 | | |
560 | 588 | | |
561 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
562 | 592 | | |
563 | 593 | | |
564 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
478 | 480 | | |
479 | 481 | | |
480 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
Lines changed: 155 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
181 | 336 | | |
182 | 337 | | |
183 | 338 | | |
| |||
0 commit comments