@bobfrankston/iflow-direct 0.1.44 → 0.1.46
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/imap-native.js +16 -0
- package/package.json +1 -1
package/imap-native.js
CHANGED
|
@@ -1126,7 +1126,23 @@ export class NativeImapClient {
|
|
|
1126
1126
|
return -1;
|
|
1127
1127
|
}
|
|
1128
1128
|
processBuffer() {
|
|
1129
|
+
// Time-budget the synchronous processing so a large FETCH burst
|
|
1130
|
+
// (sync of many envelopes in a single data chunk) doesn't starve
|
|
1131
|
+
// the Node event loop. Without this yield, IPC dispatchers in the
|
|
1132
|
+
// same process can wait 10+ seconds to get cycles — visible as
|
|
1133
|
+
// `mailxapi timeout: getMessage` / `getUnifiedInbox` on the desktop
|
|
1134
|
+
// client during heavy sync (Bob 2026-05-15: log shows daemon doing
|
|
1135
|
+
// hundreds of literal-consumed per second; client IPCs starve and
|
|
1136
|
+
// hit 30s ceiling). 10 ms budget = the same time slice Node uses
|
|
1137
|
+
// for I/O; after that we yield via setImmediate so timers, IPC,
|
|
1138
|
+
// and other I/O get a turn, then resume.
|
|
1139
|
+
const t0 = performance.now();
|
|
1140
|
+
const TIME_BUDGET_MS = 10;
|
|
1129
1141
|
while (true) {
|
|
1142
|
+
if (performance.now() - t0 > TIME_BUDGET_MS) {
|
|
1143
|
+
setImmediate(() => this.processBuffer());
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1130
1146
|
// Check for literal — `{N}` announces N octets of arbitrary data
|
|
1131
1147
|
// (message body, MIME part, attachment chunk). The buffer is
|
|
1132
1148
|
// bytes; the check is a direct length compare and the slice is
|