Commit 155bcb7
committed
fix(voip): guard CallLifecycle.end against re-entry and step-1 throws
Blocker 1: mediaCall.hangup() emits 'ended' synchronously
(@rocket.chat/media-signaling Call.js line 703). The 'ended' listener in
useCallStore re-calls callLifecycle.end('remote') BEFORE the outer
end() finishes assigning _endPromise — bypassing the re-entry guard and
triggering double teardown (callEnded twice, end command twice, infinite
recursion in tests). Defer _runTeardown to a microtask so _endPromise
is captured first; the synchronous re-entrant call now hits the guard
and shares the in-flight promise.
Blocker 3: wrap step 1 (mediaCall.reject/hangup) in try/catch with a
logger.warn so a throw does not abort subsequent teardown steps
(markActive, markAvailable, store reset, stopAudio, callEnded), which
would leak listeners and native CallKit/Telecom state.
Tests: regression for synchronous re-entry asserts callEnded fires
exactly once (toHaveBeenCalledTimes/toHaveLength) and the end command
issues exactly once. Step-1 throw isolation tests assert the remaining
six steps still run when reject/hangup throws. Integration tests
updated to flush the new teardown microtask via await act().1 parent acc3e8d commit 155bcb7
3 files changed
Lines changed: 175 additions & 15 deletions
File tree
- app
- containers/NewMediaCall
- lib/services/voip
Lines changed: 18 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
| 455 | + | |
455 | 456 | | |
| 457 | + | |
456 | 458 | | |
457 | 459 | | |
458 | 460 | | |
| |||
639 | 641 | | |
640 | 642 | | |
641 | 643 | | |
642 | | - | |
| 644 | + | |
| 645 | + | |
643 | 646 | | |
| 647 | + | |
644 | 648 | | |
645 | 649 | | |
646 | 650 | | |
| |||
651 | 655 | | |
652 | 656 | | |
653 | 657 | | |
654 | | - | |
| 658 | + | |
655 | 659 | | |
656 | 660 | | |
657 | 661 | | |
658 | 662 | | |
659 | 663 | | |
660 | 664 | | |
661 | 665 | | |
662 | | - | |
| 666 | + | |
| 667 | + | |
663 | 668 | | |
| 669 | + | |
664 | 670 | | |
665 | 671 | | |
666 | 672 | | |
| |||
670 | 676 | | |
671 | 677 | | |
672 | 678 | | |
673 | | - | |
| 679 | + | |
674 | 680 | | |
675 | 681 | | |
676 | 682 | | |
677 | 683 | | |
678 | 684 | | |
679 | 685 | | |
680 | 686 | | |
681 | | - | |
| 687 | + | |
| 688 | + | |
682 | 689 | | |
| 690 | + | |
683 | 691 | | |
684 | 692 | | |
685 | 693 | | |
| |||
814 | 822 | | |
815 | 823 | | |
816 | 824 | | |
817 | | - | |
| 825 | + | |
818 | 826 | | |
819 | 827 | | |
820 | 828 | | |
| |||
826 | 834 | | |
827 | 835 | | |
828 | 836 | | |
829 | | - | |
| 837 | + | |
| 838 | + | |
830 | 839 | | |
| 840 | + | |
831 | 841 | | |
832 | 842 | | |
833 | 843 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
359 | 488 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
| |||
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
| 140 | + | |
| 141 | + | |
128 | 142 | | |
129 | 143 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
134 | 155 | | |
135 | 156 | | |
136 | 157 | | |
| |||
0 commit comments