fix(quick-261005-d5d): Postfach-Abruf ueber EWS mit 60-s-Zeitgrenze
Tessera CI/CD / Lint & Type Check (push) Successful in 52s
Tessera CI/CD / Tests (push) Successful in 1m45s
Tessera CI/CD / Desktop-Pakete bauen (push) Successful in 20s
Tessera CI/CD / Build & Publish Images (push) Successful in 3m41s

Gleicher eigener Timer wie im Kalender; httpreqs timeout greift
waehrend des Verbindungsaufbaus nicht. 60 s, weil PDF-Anhaenge
geladen werden.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-05 10:26:10 +02:00
parent e49d4c7c9d
commit 831c7b8f52
4 changed files with 39 additions and 1 deletions
@@ -128,6 +128,24 @@ beforeEach(() => {
httpntlmPost.mockClear();
});
describe('ExchangeInboxProvider — Zeitgrenze (quick-261005)', () => {
it('testConnection meldet nach 60 s ohne Antwort „nicht erreichbar“ statt zu haengen', async () => {
vi.useFakeTimers();
try {
httpntlmPost.mockImplementation(() => {
/* ruft nie zurueck — wie ein unbeantworteter Verbindungsaufbau */
});
const pending = new ExchangeInboxProvider().testConnection(BASE_CONFIG);
await vi.advanceTimersByTimeAsync(60_000);
const result = await pending;
expect(result.success).toBe(false);
expect(result.message).toContain('not reachable');
} finally {
vi.useRealTimers();
}
});
});
describe('ExchangeInboxProvider.fetchMessages', () => {
it('a BodyType="HTML" GetItem response yields bodyHtml populated and bodyText empty', async () => {
mockEwsFlow(getItemHtmlResponse());
@@ -258,9 +258,28 @@ interface NtlmResponse {
body?: Buffer | string;
}
/**
* quick-261005: Obergrenze je EWS-Aufruf. Ohne sie wartete ein Aufruf auf
* eine nicht erreichbare Adresse rund zwei Minuten. 60 s statt der 15 s im
* Kalender, weil hier auch PDF-Anhaenge geladen werden.
*/
const INBOX_EWS_TIMEOUT_MS = 60_000;
function ntlmPost(opts: NtlmOptions): Promise<{ statusCode: number; body: string }> {
return new Promise((resolve, reject) => {
// Eigener Timer statt httpreqs `timeout`: dessen Leerlaufgrenze greift
// waehrend des Verbindungsaufbaus ueber den Keep-alive-Agenten von
// httpntlm nicht (gemessen 05.10., siehe calendar/providers/exchange.provider.ts).
const timer = setTimeout(() => {
reject(
Object.assign(
new Error(`EWS server not reachable (no answer within ${INBOX_EWS_TIMEOUT_MS / 1000} s)`),
{ code: 'TIMEOUT' },
),
);
}, INBOX_EWS_TIMEOUT_MS);
httpntlm.post(opts, (err, res) => {
clearTimeout(timer);
if (err) return reject(err);
resolve({
statusCode: res.statusCode,