fix(quick-261005-d5d): Kalender-Test bricht bei unerreichbarem Exchange nach 15 s ab
EWS-Aufrufe ueber httpntlm bekommen eine eigene 15-s-Zeitgrenze; httpreqs timeout greift waehrend des Verbindungsaufbaus nicht (gemessen 134 s). Netzfehler liefern im Test den Schluessel 'unreachable', das Formular meldet 'nicht erreichbar' statt 'Zugangsdaten pruefen'. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import type { AuthProviderCallback } from '@microsoft/microsoft-graph-client';
|
||||
import { CalendarEvent, CalendarProvider } from '../calendar.service';
|
||||
import {
|
||||
CalendarEvent,
|
||||
CalendarProvider,
|
||||
CalendarSourceUnreachableError,
|
||||
isNetworkUnreachableError,
|
||||
} from '../calendar.service';
|
||||
|
||||
/** Optionen, die ntlmPost() unten uebergibt — nichts darueber hinaus. */
|
||||
interface NtlmOptions {
|
||||
@@ -11,6 +16,8 @@ interface NtlmOptions {
|
||||
workstation: string;
|
||||
body: string;
|
||||
headers: Record<string, string>;
|
||||
/** Millisekunden bis zum Abbruch mit `code: 'TIMEOUT'` (siehe ntlmPost). */
|
||||
timeout: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,6 +38,13 @@ const httpntlm = require('httpntlm') as {
|
||||
post: (opts: NtlmOptions, cb: (err: Error | null, res: NtlmResponse) => void) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
* quick-261005: Ohne Grenze wartete ein EWS-Aufruf auf eine nicht
|
||||
* erreichbare Adresse rund zwei Minuten (TCP-Verbindungsaufbau des
|
||||
* Betriebssystems), der Test-Knopf hing so lange auf „wird geprueft“.
|
||||
*/
|
||||
const EWS_TIMEOUT_MS = 15_000;
|
||||
|
||||
const NS_SOAP = 'http://schemas.xmlsoap.org/soap/envelope/';
|
||||
const NS_TYPES = 'http://schemas.microsoft.com/exchange/services/2006/types';
|
||||
const NS_MESSAGES = 'http://schemas.microsoft.com/exchange/services/2006/messages';
|
||||
@@ -74,7 +88,15 @@ function extractAttr(xml: string, tag: string, attr: string): string {
|
||||
|
||||
function ntlmPost(opts: NtlmOptions): Promise<{ statusCode: number; body: string }> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Eigene Zeitgrenze zusaetzlich zu `opts.timeout`: httpreq setzt seine
|
||||
// nur als Leerlaufgrenze am Socket, die waehrend des Verbindungsaufbaus
|
||||
// ueber den Keep-alive-Agenten von httpntlm NICHT greift — gemessen
|
||||
// 05.10.: 134 s bis zum Fehler trotz `timeout: 15000`.
|
||||
const timer = setTimeout(() => {
|
||||
reject(Object.assign(new Error('EWS request timed out'), { code: 'TIMEOUT' }));
|
||||
}, opts.timeout);
|
||||
httpntlm.post(opts, (err, res) => {
|
||||
clearTimeout(timer);
|
||||
if (err) return reject(err);
|
||||
resolve({
|
||||
statusCode: res.statusCode,
|
||||
@@ -152,7 +174,10 @@ export class ExchangeProvider implements CalendarProvider {
|
||||
} else {
|
||||
return await this.testEwsConnection(source);
|
||||
}
|
||||
} catch {
|
||||
} catch (error) {
|
||||
// quick-261005: „nicht erreichbar“ getrennt melden, damit die
|
||||
// Oberflaeche nicht „Zugangsdaten pruefen“ sagt, wenn das Netz fehlt.
|
||||
if (isNetworkUnreachableError(error)) throw new CalendarSourceUnreachableError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -316,6 +341,7 @@ export class ExchangeProvider implements CalendarProvider {
|
||||
domain: source.domain ?? '',
|
||||
workstation: '',
|
||||
body: soap,
|
||||
timeout: EWS_TIMEOUT_MS,
|
||||
headers: {
|
||||
'Content-Type': 'text/xml; charset=utf-8',
|
||||
'SOAPAction': `"http://schemas.microsoft.com/exchange/services/2006/messages/${action}"`,
|
||||
|
||||
Reference in New Issue
Block a user