Commit d4f49b3
feat(rate-limiter): make hosted-key queue waits abort-interruptible
Replace the plain capped sleeps in the queue-head and bucket-capacity wait
loops with an interruptibleSleep that resolves early when the execution
AbortSignal fires (timeout or cancellation), cleaning up its own timer and
listener. Previously a cancelled/timed-out run could overshoot by up to the
heartbeat cap (~10s) before the loop re-checked its budget; now it wakes
within a tick. The cap remains for heartbeat renewal.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 71cb2c0 commit d4f49b3
2 files changed
Lines changed: 63 additions & 6 deletions
File tree
- apps/sim/lib/core/rate-limiter/hosted-key
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 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 | + | |
396 | 426 | | |
397 | 427 | | |
398 | 428 | | |
| |||
Lines changed: 33 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
56 | 78 | | |
57 | 79 | | |
58 | 80 | | |
| |||
416 | 438 | | |
417 | 439 | | |
418 | 440 | | |
419 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
420 | 444 | | |
421 | 445 | | |
422 | 446 | | |
423 | 447 | | |
424 | 448 | | |
425 | 449 | | |
426 | | - | |
| 450 | + | |
| 451 | + | |
427 | 452 | | |
428 | 453 | | |
429 | 454 | | |
430 | 455 | | |
431 | 456 | | |
432 | 457 | | |
433 | | - | |
| 458 | + | |
434 | 459 | | |
435 | 460 | | |
436 | 461 | | |
| |||
463 | 488 | | |
464 | 489 | | |
465 | 490 | | |
466 | | - | |
| 491 | + | |
467 | 492 | | |
468 | 493 | | |
469 | 494 | | |
| |||
507 | 532 | | |
508 | 533 | | |
509 | 534 | | |
510 | | - | |
| 535 | + | |
| 536 | + | |
511 | 537 | | |
512 | 538 | | |
513 | 539 | | |
| |||
558 | 584 | | |
559 | 585 | | |
560 | 586 | | |
561 | | - | |
| 587 | + | |
| 588 | + | |
562 | 589 | | |
563 | 590 | | |
564 | 591 | | |
| |||
0 commit comments