fix(quick-261005-d5d): Postfach-Abruf ueber EWS mit 60-s-Zeitgrenze
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user