Commit 94a53fb
committed
serve: bound /usage per provider so one slow provider can't stall the response
`serveUsage` collected providers in a sequential loop with no per-provider
timeout, so a single slow or hung provider (e.g. a CLI/web fetch that never
returns) blocked the whole `/usage` handler. The only backstop was the outer
request deadline, which returns a 504 with an empty body and discards every
provider already collected — and because that 504 is not `.ok`, the
last-known-good merge (`mergeLastGoodUsageItems`, which requires `.ok`) never
ran. Net effect: one stuck provider made the entire endpoint return nothing,
which pushed shell/Zellij consumers onto degraded CLI fallback.
Collect providers concurrently, bounding each with `BoundedTaskJoin` at a
budget strictly below the outer request deadline (`serveProviderTimeout`).
A provider over budget now contributes a provider error row instead of
blocking the others, so the response stays `.ok`, the cache can restore that
row from last-known-good, and every healthy provider still renders. Each
provider's timeout clock starts when its task is spawned, so a hung provider
cannot serialize the others' deadlines. Results merge in caller-provided
provider order regardless of completion order. The serve usage context's
`webTimeout` is aligned to the per-provider budget (was a fixed 60s that
exceeded the 30s request deadline).
Adds CLIServeRouterTests coverage for the timeout budget and for a hung
provider degrading to an error row without blocking siblings.1 parent ada3660 commit 94a53fb
3 files changed
Lines changed: 142 additions & 7 deletions
File tree
- Sources/CodexBarCLI
- Tests/CodexBarTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
422 | 430 | | |
423 | 431 | | |
424 | 432 | | |
| |||
561 | 569 | | |
562 | 570 | | |
563 | 571 | | |
564 | | - | |
| 572 | + | |
| 573 | + | |
565 | 574 | | |
566 | 575 | | |
567 | 576 | | |
| |||
691 | 700 | | |
692 | 701 | | |
693 | 702 | | |
694 | | - | |
| 703 | + | |
| 704 | + | |
695 | 705 | | |
696 | 706 | | |
697 | 707 | | |
| |||
710 | 720 | | |
711 | 721 | | |
712 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
713 | 729 | | |
714 | 730 | | |
715 | 731 | | |
| |||
718 | 734 | | |
719 | 735 | | |
720 | 736 | | |
721 | | - | |
| 737 | + | |
722 | 738 | | |
723 | 739 | | |
724 | 740 | | |
| |||
731 | 747 | | |
732 | 748 | | |
733 | 749 | | |
734 | | - | |
735 | | - | |
736 | | - | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
737 | 755 | | |
738 | 756 | | |
739 | 757 | | |
740 | 758 | | |
741 | 759 | | |
742 | 760 | | |
743 | | - | |
744 | 761 | | |
745 | 762 | | |
746 | 763 | | |
747 | 764 | | |
748 | 765 | | |
749 | 766 | | |
750 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
751 | 839 | | |
752 | 840 | | |
753 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 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 | + | |
224 | 270 | | |
225 | 271 | | |
226 | 272 | | |
| |||
0 commit comments