Commit 80e9686
authored
fix(live): preserve caller queues and prevent uncertain WebSocket replay (openai#3980)
If a Live connection opened with an empty manager queue, iterator
recovery lost the caller's queued messages and byte budget. A typed
command could also be sent again after the first socket actually
received it but its send raised. Keep the passed queue even when empty
and drop only the attempted message on a failed send/flush, leaving
unattempted messages ordered. This matches the merged Realtime handling.
Primary, fork and sideband fixes are separate commits for review. No
startup, auth, default reconnect, imports or public method signatures
change. Direct send errors still raise; queued flush failures still log
the existing warning. The Live helper notes describe the recovery and
recording-error policy.
Validation:
- Baseline: 337 Live/redirect tests pass under both Pydantic 1 and 2.
- Reproduced all 18 queue/replay failures using actual loopback wire
delivery, then 42 role tests pass, including per-role
error/unknown-event/close ordering and helper disposal.
- Final 399 Live, protected dial, Realtime and send-queue tests pass in
each Pydantic lane; Ruff and full SDK Mypy (1,865 source files) pass.
- Trusted main budget/isolation pass: 7,826/10,000 with unchanged
generated snapshot. Independent review found only the queued-error doc
clarification, which is included.1 parent 78074d7 commit 80e9686
5 files changed
Lines changed: 341 additions & 63 deletions
File tree
- src/openai
- lib/live
- resources/live
- tests/lib/live
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 218 | + | |
223 | 219 | | |
224 | 220 | | |
225 | 221 | | |
| |||
324 | 320 | | |
325 | 321 | | |
326 | 322 | | |
327 | | - | |
| 323 | + | |
328 | 324 | | |
329 | 325 | | |
330 | 326 | | |
| |||
638 | 634 | | |
639 | 635 | | |
640 | 636 | | |
641 | | - | |
| 637 | + | |
642 | 638 | | |
643 | 639 | | |
644 | 640 | | |
| |||
714 | 710 | | |
715 | 711 | | |
716 | 712 | | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
| 713 | + | |
722 | 714 | | |
723 | 715 | | |
724 | 716 | | |
| |||
817 | 809 | | |
818 | 810 | | |
819 | 811 | | |
820 | | - | |
| 812 | + | |
821 | 813 | | |
822 | 814 | | |
823 | 815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 439 | + | |
444 | 440 | | |
445 | 441 | | |
446 | 442 | | |
| |||
545 | 541 | | |
546 | 542 | | |
547 | 543 | | |
548 | | - | |
| 544 | + | |
549 | 545 | | |
550 | 546 | | |
551 | 547 | | |
| |||
856 | 852 | | |
857 | 853 | | |
858 | 854 | | |
859 | | - | |
| 855 | + | |
860 | 856 | | |
861 | 857 | | |
862 | 858 | | |
| |||
932 | 928 | | |
933 | 929 | | |
934 | 930 | | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
| 931 | + | |
940 | 932 | | |
941 | 933 | | |
942 | 934 | | |
| |||
1035 | 1027 | | |
1036 | 1028 | | |
1037 | 1029 | | |
1038 | | - | |
| 1030 | + | |
1039 | 1031 | | |
1040 | 1032 | | |
1041 | 1033 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 221 | + | |
226 | 222 | | |
227 | 223 | | |
228 | 224 | | |
| |||
329 | 325 | | |
330 | 326 | | |
331 | 327 | | |
332 | | - | |
| 328 | + | |
333 | 329 | | |
334 | 330 | | |
335 | 331 | | |
| |||
646 | 642 | | |
647 | 643 | | |
648 | 644 | | |
649 | | - | |
| 645 | + | |
650 | 646 | | |
651 | 647 | | |
652 | 648 | | |
| |||
722 | 718 | | |
723 | 719 | | |
724 | 720 | | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
| 721 | + | |
730 | 722 | | |
731 | 723 | | |
732 | 724 | | |
| |||
827 | 819 | | |
828 | 820 | | |
829 | 821 | | |
830 | | - | |
| 822 | + | |
831 | 823 | | |
832 | 824 | | |
833 | 825 | | |
| |||
0 commit comments