


























@@ -249,6 +249,7 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
249249// Tracks accounts that were manually stopped so we don't auto-restart them.
250250const manuallyStopped = new Set<string>();
251251const recoveryStopTimedOut = new Set<string>();
252+const recoveryStartRequested = new Set<string>();
252253253254const restartKey = (channelId: ChannelId, accountId: string) => `${channelId}:${accountId}`;
254255const ensureChannelLog = (channelId: ChannelId): SubsystemLogger => {
@@ -382,6 +383,7 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
382383store.runtimes.delete(id);
383384restartAttempts.delete(restartKey(channelId, id));
384385manuallyStopped.delete(restartKey(channelId, id));
386+recoveryStartRequested.delete(restartKey(channelId, id));
385387}
386388};
387389@@ -414,7 +416,12 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
414416const startup = await runTasksWithConcurrency({
415417limit: CHANNEL_STARTUP_CONCURRENCY,
416418tasks: accountIds.map((id) => async () => {
419+const rKey = restartKey(channelId, id);
417420if (store.tasks.has(id)) {
421+if (recoveryStopTimedOut.has(rKey)) {
422+recoveryStartRequested.add(rKey);
423+setRuntime(channelId, id, { accountId: id, restartPending: true });
424+}
418425return;
419426}
420427const existingStart = store.starting.get(id);
@@ -490,7 +497,6 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
490497return;
491498}
492499493-const rKey = restartKey(channelId, id);
494500if (!preserveManualStop) {
495501manuallyStopped.delete(rKey);
496502}
@@ -595,10 +601,25 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
595601.then(async () => {
596602if (manuallyStopped.has(rKey)) {
597603recoveryStopTimedOut.delete(rKey);
604+recoveryStartRequested.delete(rKey);
598605return;
599606}
600607if (recoveryStopTimedOut.has(rKey)) {
601608recoveryStopTimedOut.delete(rKey);
609+if (!recoveryStartRequested.delete(rKey)) {
610+setRuntime(channelId, id, {
611+accountId: id,
612+restartPending: false,
613+reconnectAttempts: 0,
614+});
615+if (store.tasks.get(id) === trackedPromise) {
616+store.tasks.delete(id);
617+}
618+if (store.aborts.get(id) === abort) {
619+store.aborts.delete(id);
620+}
621+return;
622+}
602623restartAttempts.delete(rKey);
603624log.info?.(`[${id}] restarting after timed-out channel stop completed`);
604625setRuntime(channelId, id, {
@@ -774,6 +795,7 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
774795return;
775796}
776797recoveryStopTimedOut.delete(rKey);
798+recoveryStartRequested.delete(rKey);
777799store.aborts.delete(id);
778800store.tasks.delete(id);
779801setRuntime(channelId, id, {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。