@commonlyai/cli 0.1.365 → 0.1.366
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/agent.js +70 -0
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -3838,6 +3838,13 @@ export const performRun = ({
|
|
|
3838
3838
|
// The arguments of the turn that just threw, for noticeCutOff.
|
|
3839
3839
|
let failedTurn = null;
|
|
3840
3840
|
let heldRenewTimer = null;
|
|
3841
|
+
// Renews the rows a tick claimed for its later pods while an earlier pod's
|
|
3842
|
+
// turn runs (F237). Cleared when the tick's groups are done.
|
|
3843
|
+
let laterGroupsRenewTimer = null;
|
|
3844
|
+
const clearLaterGroupsRenewal = () => {
|
|
3845
|
+
if (laterGroupsRenewTimer !== null) clearIntervalImpl(laterGroupsRenewTimer);
|
|
3846
|
+
laterGroupsRenewTimer = null;
|
|
3847
|
+
};
|
|
3841
3848
|
const clearHeldRenewal = () => {
|
|
3842
3849
|
if (heldRenewTimer !== null) clearIntervalImpl(heldRenewTimer);
|
|
3843
3850
|
heldRenewTimer = null;
|
|
@@ -4662,8 +4669,70 @@ export const performRun = ({
|
|
|
4662
4669
|
// alongside a wake on the same page, and a private wake groups apart
|
|
4663
4670
|
// from it, so a digest-only group here can be `delivered` to this run.
|
|
4664
4671
|
const claimedAfter = (groupIndex) => groups.slice(groupIndex + 1).flat();
|
|
4672
|
+
// F237 item 1: the page's groups run one turn at a time, and a later
|
|
4673
|
+
// group's rows were claimed when the page was read. A turn may run 15
|
|
4674
|
+
// minutes and the server requeues a delivered row after 10, so they are
|
|
4675
|
+
// renewed while an earlier group runs. A row the server says is no
|
|
4676
|
+
// longer this runner's is taken out before its group starts: its ack
|
|
4677
|
+
// would be a stale delivery, which stops the run, and the requeue
|
|
4678
|
+
// redelivers it.
|
|
4679
|
+
// Bounded by the running turn's deadline, as processEventBatch bounds
|
|
4680
|
+
// its own renewal: a turn whose child ignores SIGTERM can hang, and the
|
|
4681
|
+
// rows behind it must lapse to the requeue rather than stay with it.
|
|
4682
|
+
let firstWaitingGroup = 1;
|
|
4683
|
+
let runningGroupSince = Date.now();
|
|
4684
|
+
let deadlineLogged = false;
|
|
4685
|
+
// One renewal at a time. A group's turn waits for one still out, so the
|
|
4686
|
+
// groups it names have not started when its answer is applied
|
|
4687
|
+
// (CodeRabbit on #4067).
|
|
4688
|
+
let renewingLater = null;
|
|
4689
|
+
clearLaterGroupsRenewal();
|
|
4690
|
+
if (groups.length > 1) {
|
|
4691
|
+
laterGroupsRenewTimer = setIntervalImpl(async () => {
|
|
4692
|
+
if (!running) {
|
|
4693
|
+
clearLaterGroupsRenewal();
|
|
4694
|
+
return;
|
|
4695
|
+
}
|
|
4696
|
+
if (renewingLater) return;
|
|
4697
|
+
// Skipped, not stopped: the next group restarts the clock, and its
|
|
4698
|
+
// turn needs the rows behind it renewed again.
|
|
4699
|
+
if (Date.now() - runningGroupSince >= effectiveTurnTimeoutMs) {
|
|
4700
|
+
if (!deadlineLogged) {
|
|
4701
|
+
deadlineLogged = true;
|
|
4702
|
+
log('[inbox.batch] turn deadline reached; renewal of the later pods\' rows paused while this turn overruns');
|
|
4703
|
+
}
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
const from = firstWaitingGroup;
|
|
4707
|
+
renewingLater = (async () => {
|
|
4708
|
+
const confirmed = await renewHeldDeliveries(claimedAfter(from - 1));
|
|
4709
|
+
if (confirmed === null) return;
|
|
4710
|
+
let lost = 0;
|
|
4711
|
+
for (let later = from; later < groups.length; later += 1) {
|
|
4712
|
+
const kept = groups[later].filter((event) => stillHeld(event, confirmed));
|
|
4713
|
+
lost += groups[later].length - kept.length;
|
|
4714
|
+
groups[later] = kept;
|
|
4715
|
+
}
|
|
4716
|
+
if (lost) {
|
|
4717
|
+
log(
|
|
4718
|
+
`[inbox.batch] ${countEvents(lost)} no longer held by this runner on the server while `
|
|
4719
|
+
+ 'another pod\'s turn ran — not run; the server redelivers it',
|
|
4720
|
+
);
|
|
4721
|
+
}
|
|
4722
|
+
})().finally(() => { renewingLater = null; });
|
|
4723
|
+
await renewingLater;
|
|
4724
|
+
}, DELIVERY_RENEW_INTERVAL_MS);
|
|
4725
|
+
laterGroupsRenewTimer?.unref?.();
|
|
4726
|
+
}
|
|
4665
4727
|
for (let groupIndex = 0; groupIndex < groups.length; groupIndex += 1) {
|
|
4728
|
+
// renewHeldDeliveries never throws: a failed renewal resolves null.
|
|
4729
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4730
|
+
if (renewingLater) await renewingLater;
|
|
4731
|
+
firstWaitingGroup = groupIndex + 1;
|
|
4732
|
+
runningGroupSince = Date.now();
|
|
4733
|
+
deadlineLogged = false;
|
|
4666
4734
|
const group = groups[groupIndex];
|
|
4735
|
+
if (group.length === 0) continue;
|
|
4667
4736
|
if (!running) {
|
|
4668
4737
|
// Claimed by this tick's poll (or carried into it) and never run:
|
|
4669
4738
|
// a stop that arrived mid-poll or mid-page (F182). Handed back when
|
|
@@ -5001,6 +5070,7 @@ export const performRun = ({
|
|
|
5001
5070
|
}
|
|
5002
5071
|
onError?.(err);
|
|
5003
5072
|
}
|
|
5073
|
+
clearLaterGroupsRenewal();
|
|
5004
5074
|
// Notices landing during a turn share one three-second collection window
|
|
5005
5075
|
// before the next inbox read, independent of the idle polling cadence. A
|
|
5006
5076
|
// retry scheduled in the same tick keeps its own delay: the failure report
|