@bobfrankston/rmfmail 1.2.48 → 1.2.49
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 +3 -3
- package/packages/mailx-imap/index.d.ts +44 -44
- package/packages/mailx-imap/index.d.ts.map +1 -1
- package/packages/mailx-imap/index.js +132 -131
- package/packages/mailx-imap/index.js.map +1 -1
- package/packages/mailx-imap/index.ts +131 -134
- package/packages/mailx-imap/package-lock.json +2 -2
- package/packages/mailx-imap/package.json +1 -1
|
@@ -24,15 +24,13 @@ const SMTP_PORT_STARTTLS = 587;
|
|
|
24
24
|
const SMTP_PORT_IMPLICIT_TLS = 465;
|
|
25
25
|
|
|
26
26
|
type OpsTask = () => Promise<void>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
runningFast: boolean;
|
|
35
|
-
runningSlow: boolean;
|
|
27
|
+
/** One FIFO task queue per (account, lane). All lanes drain concurrently —
|
|
28
|
+
* each lane runs on its own persistent connection — so a slow op on one lane
|
|
29
|
+
* never blocks another. Within a lane, strictly sequential (one IMAP command
|
|
30
|
+
* in flight, no SELECT races). */
|
|
31
|
+
interface LaneQueue {
|
|
32
|
+
tasks: OpsTask[];
|
|
33
|
+
running: boolean;
|
|
36
34
|
}
|
|
37
35
|
interface HostSemaphore {
|
|
38
36
|
permits: number;
|
|
@@ -591,39 +589,45 @@ export class ImapManager extends EventEmitter {
|
|
|
591
589
|
// No semaphore, no pool, no per-operation connect/disconnect.
|
|
592
590
|
// IDLE uses a separate connection (see startWatching).
|
|
593
591
|
|
|
594
|
-
/**
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
*
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
592
|
+
/** Per-workload connection lanes. Each (lane, account) gets its OWN
|
|
593
|
+
* persistent IMAP connection so a slow op on one lane can't block another:
|
|
594
|
+
* a 90s `SELECT Sent` on "outbox" or a giant `UID FETCH` on "prefetch" no
|
|
595
|
+
* longer wedges INBOX sync/backfill on "sync". This is the root fix for
|
|
596
|
+
* the "whole sync worker goes silent" wedge (Bob 2026-06-20): before, all
|
|
597
|
+
* background work shared ONE slow connection and serialized behind the
|
|
598
|
+
* slowest command (a 90s SELECT Sent / a giant prefetch FETCH stalled
|
|
599
|
+
* INBOX backfill behind it). Lanes in use:
|
|
600
|
+
* fast — interactive: body fetch on click, flag toggle, move
|
|
601
|
+
* slow — folder sync + set-diff backfill (the `{slow:true}` default)
|
|
602
|
+
* prefetch — background body download (heaviest, longest)
|
|
603
|
+
* outbox — send + sent-sweep + Outbox/Sent SELECT/APPEND
|
|
604
|
+
* Per account that's ≤4 persistent sockets + 1 IDLE, under Dovecot's 20.
|
|
605
|
+
* laneName → (accountId → persistent client). */
|
|
606
|
+
private laneClients = new Map<string, Map<string, any>>();
|
|
607
|
+
/** Per-account, per-lane FIFO task queues. accountId → (laneName → queue).
|
|
608
|
+
* All lanes for an account drain concurrently (each on its own socket);
|
|
609
|
+
* within a lane, strictly sequential — no SELECT race. */
|
|
610
|
+
private laneQueues = new Map<string, Map<string, LaneQueue>>();
|
|
611
611
|
/** Per-host semaphore — caps simultaneous IMAP socket opens to one server.
|
|
612
|
-
* Defensive guardrail
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
612
|
+
* Defensive guardrail for the multi-account-on-one-host case (e.g. bobma +
|
|
613
|
+
* bobma2 both on imap.iecc.com). NOTE: the permit is held for the
|
|
614
|
+
* connection's LIFETIME (released on logout/destroy), not just the open —
|
|
615
|
+
* so this also bounds the number of live persistent connections per host.
|
|
616
|
+
* Each account now keeps up to 4 persistent lanes (fast/slow/prefetch/
|
|
617
|
+
* outbox) + 1 IDLE (IDLE bypasses the semaphore). 8 permits covers two
|
|
618
|
+
* accounts' lanes with headroom, still far under Dovecot's ~20/user+IP. */
|
|
616
619
|
private hostSemaphores = new Map<string, HostSemaphore>();
|
|
617
|
-
private static readonly HOST_PERMITS =
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
620
|
+
private static readonly HOST_PERMITS = 8;
|
|
621
|
+
|
|
622
|
+
/** The (accountId → client) map for a lane, created on first use. */
|
|
623
|
+
private laneClientMap(lane: string): Map<string, any> {
|
|
624
|
+
let m = this.laneClients.get(lane);
|
|
625
|
+
if (!m) { m = new Map(); this.laneClients.set(lane, m); }
|
|
626
|
+
return m;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
private async getLaneClient(accountId: string, lane: string): Promise<any> {
|
|
630
|
+
const map = this.laneClientMap(lane);
|
|
627
631
|
let client = map.get(accountId);
|
|
628
632
|
if (client) {
|
|
629
633
|
// C38: health-check the cached client before returning. If the
|
|
@@ -640,7 +644,7 @@ export class ImapManager extends EventEmitter {
|
|
|
640
644
|
console.log(` [conn] ${accountId}: stale ${lane} client detected — reconnecting`);
|
|
641
645
|
client = undefined as any;
|
|
642
646
|
}
|
|
643
|
-
client = await this.newClient(accountId, lane
|
|
647
|
+
client = await this.newClient(accountId, lane);
|
|
644
648
|
// Wrap logout as no-op — this is a persistent connection. The
|
|
645
649
|
// newClient wrapper's close-counter runs on `_realLogout`.
|
|
646
650
|
const realLogout = client.logout.bind(client);
|
|
@@ -657,33 +661,30 @@ export class ImapManager extends EventEmitter {
|
|
|
657
661
|
return this.getLaneClient(accountId, "slow");
|
|
658
662
|
}
|
|
659
663
|
|
|
660
|
-
/** Run an operation
|
|
661
|
-
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
* recovery" paths the old multi-client design needed.
|
|
664
|
+
/** Run an operation against one of the account's per-workload lane
|
|
665
|
+
* connections. Tasks queue strictly sequentially WITHIN a lane (one IMAP
|
|
666
|
+
* command in flight, no SELECT race) but lanes run CONCURRENTLY, each on
|
|
667
|
+
* its own socket — so a slow op on one lane never blocks another.
|
|
665
668
|
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
* When both lanes have tasks, fast drains first.
|
|
669
|
+
* Pick the lane via `opts.lane` (e.g. "sync", "prefetch", "outbox").
|
|
670
|
+
* Default is "fast" — interactive ops (body fetch on click, flag toggle,
|
|
671
|
+
* move). `slow: true` is a legacy alias for the "slow" misc lane; prefer
|
|
672
|
+
* a named lane so distinct workloads don't serialize behind each other.
|
|
671
673
|
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
+
* The running task always finishes — IMAP can't preempt a command
|
|
675
|
+
* mid-flight; the wall-clock timeout below bounds how long that can be. */
|
|
674
676
|
async withConnection<T>(
|
|
675
677
|
accountId: string,
|
|
676
678
|
fn: (client: any) => Promise<T>,
|
|
677
|
-
opts: { slow?: boolean; timeoutMs?: number } = {},
|
|
679
|
+
opts: { slow?: boolean; lane?: string; timeoutMs?: number } = {},
|
|
678
680
|
): Promise<T> {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
const lane: "fast" | "slow" = opts.slow ? "slow" : "fast";
|
|
681
|
+
const lane: string = opts.lane ?? (opts.slow ? "slow" : "fast");
|
|
682
|
+
let perAccount = this.laneQueues.get(accountId);
|
|
683
|
+
if (!perAccount) { perAccount = new Map(); this.laneQueues.set(accountId, perAccount); }
|
|
684
|
+
let queue = perAccount.get(lane);
|
|
685
|
+
if (!queue) { queue = { tasks: [], running: false }; perAccount.set(lane, queue); }
|
|
685
686
|
// Per-task wall-clock cap. Without one, a wedged IMAP command (TCP
|
|
686
|
-
// half-open, server stalled mid-FETCH) keeps the
|
|
687
|
+
// half-open, server stalled mid-FETCH) keeps the lane's running flag
|
|
687
688
|
// set forever and every subsequent same-lane task — including the
|
|
688
689
|
// retry button the user just hit — waits behind it. Default is
|
|
689
690
|
// generous; callers driving user-visible reads pass a tighter value.
|
|
@@ -703,13 +704,12 @@ export class ImapManager extends EventEmitter {
|
|
|
703
704
|
resolve(result);
|
|
704
705
|
} catch (e: any) {
|
|
705
706
|
clearTimeout(timer);
|
|
706
|
-
// Discard
|
|
707
|
-
// socket poisons every subsequent request on
|
|
708
|
-
//
|
|
709
|
-
//
|
|
710
|
-
//
|
|
711
|
-
|
|
712
|
-
const map = lane === "fast" ? this.fastClients : this.opsClients;
|
|
707
|
+
// Discard THIS lane's client on any error — a half-broken
|
|
708
|
+
// socket poisons every subsequent request on the lane.
|
|
709
|
+
// Other lanes' clients are independent and untouched.
|
|
710
|
+
// Destroy synchronously kills the in-flight command's
|
|
711
|
+
// socket so the underlying promise rejects.
|
|
712
|
+
const map = this.laneClientMap(lane);
|
|
713
713
|
const stale = map.get(accountId);
|
|
714
714
|
map.delete(accountId);
|
|
715
715
|
if (stale) {
|
|
@@ -719,31 +719,27 @@ export class ImapManager extends EventEmitter {
|
|
|
719
719
|
reject(e);
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
|
-
queue
|
|
722
|
+
queue!.tasks.push(task);
|
|
723
723
|
this.drainOpsQueue(accountId);
|
|
724
724
|
});
|
|
725
725
|
}
|
|
726
726
|
|
|
727
|
-
/**
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
* same lane. */
|
|
727
|
+
/** Drain the next queued task on EVERY lane for the account. Lanes run
|
|
728
|
+
* concurrently — each on its own connection — and the per-lane running
|
|
729
|
+
* flag prevents reentrant draining of the same lane. */
|
|
731
730
|
private drainOpsQueue(accountId: string): void {
|
|
732
|
-
const
|
|
733
|
-
if (!
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
queue[runningKey] = true;
|
|
731
|
+
const perAccount = this.laneQueues.get(accountId);
|
|
732
|
+
if (!perAccount) return;
|
|
733
|
+
for (const queue of perAccount.values()) {
|
|
734
|
+
if (queue.running) continue;
|
|
735
|
+
const next = queue.tasks.shift();
|
|
736
|
+
if (!next) continue;
|
|
737
|
+
queue.running = true;
|
|
740
738
|
next().finally(() => {
|
|
741
|
-
queue
|
|
742
|
-
|
|
739
|
+
queue.running = false;
|
|
740
|
+
this.drainOpsQueue(accountId);
|
|
743
741
|
});
|
|
744
|
-
}
|
|
745
|
-
drainLane("fast");
|
|
746
|
-
drainLane("slow");
|
|
742
|
+
}
|
|
747
743
|
}
|
|
748
744
|
|
|
749
745
|
/** Acquire one slot of the per-host connection semaphore. Returns a release
|
|
@@ -853,7 +849,7 @@ export class ImapManager extends EventEmitter {
|
|
|
853
849
|
* so the server's connection slots free immediately rather than
|
|
854
850
|
* waiting for socket idle timeouts. */
|
|
855
851
|
async closeAllClients(accountId: string): Promise<void> {
|
|
856
|
-
for (const map of
|
|
852
|
+
for (const map of this.laneClients.values()) {
|
|
857
853
|
const c = map.get(accountId);
|
|
858
854
|
map.delete(accountId);
|
|
859
855
|
if (c) { try { await (c._realLogout || c.logout)(); } catch { /* */ } try { c.destroy?.(); } catch { /* */ } }
|
|
@@ -871,7 +867,7 @@ export class ImapManager extends EventEmitter {
|
|
|
871
867
|
/** Disconnect the persistent operational connections (both lanes) for
|
|
872
868
|
* an account. */
|
|
873
869
|
async disconnectOps(accountId: string): Promise<void> {
|
|
874
|
-
for (const [name, map] of
|
|
870
|
+
for (const [name, map] of this.laneClients) {
|
|
875
871
|
const client = map.get(accountId);
|
|
876
872
|
map.delete(accountId);
|
|
877
873
|
if (client) {
|
|
@@ -2524,12 +2520,15 @@ export class ImapManager extends EventEmitter {
|
|
|
2524
2520
|
return stored;
|
|
2525
2521
|
}
|
|
2526
2522
|
|
|
2527
|
-
/** Kill and recreate the persistent
|
|
2523
|
+
/** Kill and recreate the persistent connections for an account — drops the
|
|
2524
|
+
* client on every lane so the next task on each reconnects fresh. */
|
|
2528
2525
|
private async reconnectOps(accountId: string): Promise<void> {
|
|
2529
|
-
const
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2526
|
+
for (const map of this.laneClients.values()) {
|
|
2527
|
+
const old = map.get(accountId);
|
|
2528
|
+
map.delete(accountId);
|
|
2529
|
+
if (old) { try { await (old._realLogout || old.logout)(); } catch { /* */ } }
|
|
2530
|
+
}
|
|
2531
|
+
console.log(` [conn] ${accountId}: reconnecting (all lanes)`);
|
|
2533
2532
|
}
|
|
2534
2533
|
|
|
2535
2534
|
/** Handle sync errors — classify and emit appropriate UI events.
|
|
@@ -3562,7 +3561,7 @@ export class ImapManager extends EventEmitter {
|
|
|
3562
3561
|
})());
|
|
3563
3562
|
});
|
|
3564
3563
|
await Promise.all(pending);
|
|
3565
|
-
}, {
|
|
3564
|
+
}, { lane: "prefetch", timeoutMs: 300_000 });
|
|
3566
3565
|
// 5-min cap, not the 90s interactive default:
|
|
3567
3566
|
// prefetch is background, and a 25-message body
|
|
3568
3567
|
// chunk on a slow Dovecot legitimately runs past
|
|
@@ -4326,7 +4325,7 @@ export class ImapManager extends EventEmitter {
|
|
|
4326
4325
|
await this.withConnection(accountId, async (client) => {
|
|
4327
4326
|
await client.createmailbox("Outbox");
|
|
4328
4327
|
await this.syncFolders(accountId, client);
|
|
4329
|
-
});
|
|
4328
|
+
}, { lane: "outbox" });
|
|
4330
4329
|
} catch (e: any) {
|
|
4331
4330
|
// Might already exist — benign
|
|
4332
4331
|
if (!e.message?.includes("already exists")) throw e;
|
|
@@ -4437,7 +4436,7 @@ export class ImapManager extends EventEmitter {
|
|
|
4437
4436
|
await this.withConnection(accountId, async (client) => {
|
|
4438
4437
|
appendedUid = await client.appendMessage(outboxPath, rawMessage, ["\\Seen"]);
|
|
4439
4438
|
console.log(` [outbox] Queued message in ${outboxPath}${appendedUid != null ? ` (UID ${appendedUid})` : ""}`);
|
|
4440
|
-
});
|
|
4439
|
+
}, { lane: "outbox" });
|
|
4441
4440
|
if (outboxFolder) {
|
|
4442
4441
|
if (appendedUid != null) {
|
|
4443
4442
|
// Inserts the row from the source bytes we already have +
|
|
@@ -4644,7 +4643,9 @@ export class ImapManager extends EventEmitter {
|
|
|
4644
4643
|
// claim so the recovery sweeper picks it up next tick.
|
|
4645
4644
|
try {
|
|
4646
4645
|
const outboxPath = await this.ensureOutbox(accountId);
|
|
4647
|
-
|
|
4646
|
+
// Outbox lane, not the slow/sync lane — a wedged APPEND here (which
|
|
4647
|
+
// withTimeout force-closes the socket on) must not disrupt sync.
|
|
4648
|
+
const client = await this.getLaneClient(accountId, "outbox");
|
|
4648
4649
|
try {
|
|
4649
4650
|
for (const { dir, file } of filesToSend) {
|
|
4650
4651
|
const filePath = path.join(dir, file);
|
|
@@ -4780,9 +4781,9 @@ export class ImapManager extends EventEmitter {
|
|
|
4780
4781
|
const account = settings.accounts.find(a => a.id === accountId);
|
|
4781
4782
|
if (!account) return;
|
|
4782
4783
|
|
|
4783
|
-
// List UIDs first — quick command
|
|
4784
|
+
// List UIDs first — quick command on the dedicated outbox lane.
|
|
4784
4785
|
const uids = await this.withConnection(accountId, (client) =>
|
|
4785
|
-
client.getUids(outboxFolder.path)
|
|
4786
|
+
client.getUids(outboxFolder.path), { lane: "outbox" }
|
|
4786
4787
|
) as number[];
|
|
4787
4788
|
if (uids.length === 0) return;
|
|
4788
4789
|
|
|
@@ -4792,9 +4793,9 @@ export class ImapManager extends EventEmitter {
|
|
|
4792
4793
|
const sentFolder = this.findFolder(accountId, "sent");
|
|
4793
4794
|
|
|
4794
4795
|
for (const uid of uids) {
|
|
4795
|
-
// Each iteration is one
|
|
4796
|
-
//
|
|
4797
|
-
//
|
|
4796
|
+
// Each iteration is one outbox-lane turn — sync, prefetch and
|
|
4797
|
+
// fast-lane (click) work all run on their own connections, so a
|
|
4798
|
+
// long outbox drain never blocks them.
|
|
4798
4799
|
const result = await this.withConnection(accountId, async (client) => {
|
|
4799
4800
|
const flags = await client.getFlags(outboxFolder.path, uid);
|
|
4800
4801
|
|
|
@@ -4842,7 +4843,7 @@ export class ImapManager extends EventEmitter {
|
|
|
4842
4843
|
return { skip: true };
|
|
4843
4844
|
}
|
|
4844
4845
|
return { source: msg.source };
|
|
4845
|
-
}, {
|
|
4846
|
+
}, { lane: "outbox" });
|
|
4846
4847
|
|
|
4847
4848
|
if ((result as any).skip) continue;
|
|
4848
4849
|
const source = (result as any).source as string;
|
|
@@ -4858,13 +4859,13 @@ export class ImapManager extends EventEmitter {
|
|
|
4858
4859
|
await this.withConnection(accountId, async (client) => {
|
|
4859
4860
|
// Delete FIRST to prevent double-send if Sent-copy fails.
|
|
4860
4861
|
await client.deleteMessageByUid(outboxFolder.path, uid);
|
|
4861
|
-
}, {
|
|
4862
|
+
}, { lane: "outbox" });
|
|
4862
4863
|
if (sentFolder) {
|
|
4863
4864
|
let appendedSentUid: number | null = null;
|
|
4864
4865
|
try {
|
|
4865
4866
|
await this.withConnection(accountId, async (client) => {
|
|
4866
4867
|
appendedSentUid = await client.appendMessage(sentFolder.path, source, ["\\Seen"]);
|
|
4867
|
-
}, {
|
|
4868
|
+
}, { lane: "outbox" });
|
|
4868
4869
|
} catch (sentErr: any) {
|
|
4869
4870
|
console.error(` [outbox] Failed to copy to Sent: ${sentErr.message} — message was sent successfully`);
|
|
4870
4871
|
}
|
|
@@ -4894,7 +4895,7 @@ export class ImapManager extends EventEmitter {
|
|
|
4894
4895
|
await this.withConnection(accountId, async (client) => {
|
|
4895
4896
|
await client.removeFlags(outboxFolder.path, uid, [sendingFlag]);
|
|
4896
4897
|
await client.addFlags(outboxFolder.path, uid, ["$Failed"]);
|
|
4897
|
-
}, {
|
|
4898
|
+
}, { lane: "outbox" });
|
|
4898
4899
|
} catch { /* best-effort */ }
|
|
4899
4900
|
// Suppress the banner for transient network errors. ETIMEDOUT
|
|
4900
4901
|
// on a Dovecot send is the server being slow / a TCP idle
|
|
@@ -5033,10 +5034,10 @@ export class ImapManager extends EventEmitter {
|
|
|
5033
5034
|
this.outboxBackoffDelay.delete(accountId);
|
|
5034
5035
|
} catch (e: any) {
|
|
5035
5036
|
// Stale-socket errors (Dovecot silently drops idle connections,
|
|
5036
|
-
// or the sync path timed out and destroyed the socket): force
|
|
5037
|
-
// fresh
|
|
5038
|
-
// dead socket. Without reconnectOps, the dead client stays
|
|
5039
|
-
//
|
|
5037
|
+
// or the sync path timed out and destroyed the socket): force
|
|
5038
|
+
// fresh lane clients so the next tick doesn't keep hitting the
|
|
5039
|
+
// same dead socket. Without reconnectOps, the dead client stays
|
|
5040
|
+
// in its lane map and every subsequent processOutbox call fails
|
|
5040
5041
|
// immediately with "Not connected" — forever.
|
|
5041
5042
|
const msg = String(e?.message || e);
|
|
5042
5043
|
if (/Not connected|ECONNRESET|socket hang up|EPIPE|write after end/i.test(msg)) {
|
|
@@ -5136,19 +5137,18 @@ export class ImapManager extends EventEmitter {
|
|
|
5136
5137
|
if (rows.length === 0) return;
|
|
5137
5138
|
let reconciled = 0;
|
|
5138
5139
|
let appended = 0;
|
|
5139
|
-
//
|
|
5140
|
-
//
|
|
5141
|
-
//
|
|
5142
|
-
//
|
|
5143
|
-
//
|
|
5144
|
-
//
|
|
5145
|
-
//
|
|
5146
|
-
//
|
|
5147
|
-
//
|
|
5148
|
-
//
|
|
5149
|
-
//
|
|
5150
|
-
|
|
5151
|
-
try {
|
|
5140
|
+
// Run the whole sweep on the dedicated "outbox" lane — its OWN
|
|
5141
|
+
// persistent connection, separate from the slow/sync lane. Two reasons:
|
|
5142
|
+
// 1. Sent-sweep's `SELECT Sent` has been observed taking 90s on this
|
|
5143
|
+
// server; on the shared slow lane that stalled INBOX sync/backfill
|
|
5144
|
+
// behind it (the "whole worker goes silent" wedge, Bob 2026-06-20).
|
|
5145
|
+
// 2. withConnection serializes the entire SEARCH→APPEND sweep on one
|
|
5146
|
+
// connection, so it can't interleave mid-transaction with another
|
|
5147
|
+
// task's SELECT (the "BAD No mailbox selected" class, Bob
|
|
5148
|
+
// 2026-05-25). Previously this used createClientWithLimit() — which
|
|
5149
|
+
// actually returned the SHARED slow client and then destroyed it in
|
|
5150
|
+
// a finally, the opposite of "dedicated".
|
|
5151
|
+
await this.withConnection(accountId, async (client) => {
|
|
5152
5152
|
for (const row of rows) {
|
|
5153
5153
|
const msgId = row.message_id;
|
|
5154
5154
|
if (!msgId) continue;
|
|
@@ -5185,10 +5185,7 @@ export class ImapManager extends EventEmitter {
|
|
|
5185
5185
|
}
|
|
5186
5186
|
}
|
|
5187
5187
|
}
|
|
5188
|
-
}
|
|
5189
|
-
try { await (client._realLogout || client.logout)(); } catch { /* */ }
|
|
5190
|
-
try { client.destroy?.(); } catch { /* */ }
|
|
5191
|
-
}
|
|
5188
|
+
}, { lane: "outbox", timeoutMs: 120_000 });
|
|
5192
5189
|
if (reconciled + appended > 0) {
|
|
5193
5190
|
this.emit("folderCountsChanged", accountId, {});
|
|
5194
5191
|
console.log(` [sent-sweep] ${accountId}: ${reconciled} rebound, ${appended} re-appended`);
|
|
@@ -5469,13 +5466,13 @@ export class ImapManager extends EventEmitter {
|
|
|
5469
5466
|
this.stopPeriodicSync();
|
|
5470
5467
|
this.stopOutboxWorker();
|
|
5471
5468
|
await this.stopWatching();
|
|
5472
|
-
// Disconnect persistent connections on
|
|
5473
|
-
// because
|
|
5474
|
-
//
|
|
5475
|
-
const accountIds = new Set<string>(
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5469
|
+
// Disconnect persistent connections on every lane. Union across all
|
|
5470
|
+
// lane maps because a lane can hold an account the others don't (e.g.
|
|
5471
|
+
// body fetches happened on "fast" but no sync ran on "sync").
|
|
5472
|
+
const accountIds = new Set<string>();
|
|
5473
|
+
for (const map of this.laneClients.values()) {
|
|
5474
|
+
for (const k of map.keys()) accountIds.add(k);
|
|
5475
|
+
}
|
|
5479
5476
|
for (const accountId of accountIds) {
|
|
5480
5477
|
await this.disconnectOps(accountId);
|
|
5481
5478
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-imap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.105",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@bobfrankston/mailx-imap",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.105",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@bobfrankston/iflow-direct": "^0.1.27",
|