Skip to content

fix(alerting): hard timeout on ANS raise — admin test alert fails fast instead of 502 - #1505

Merged
jung-thomas merged 1 commit into
mainfrom
fix/alert-raise-timeout
Aug 6, 2026
Merged

fix(alerting): hard timeout on ANS raise — admin test alert fails fast instead of 502#1505
jung-thomas merged 1 commit into
mainfrom
fix/alert-raise-timeout

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

After the kinds fix (#1503) made cds.connect.to('alerts') succeed, the admin Send test alert started failing with Gateway Timeout. PROD srv log: POST /admin/ChatSettings/AdminService.sendTestAlert → 502 endpoint_failure (EOF) response_time:86.3s.

Root cause

The ANS sink in @sap-tutorials/cds-alert-notification (lib/sinks/ans-client.js) delivers via a raw globalThis.fetch with no AbortController/timeout. A hung ANS connection (blocked CF egress is the prime suspect — both ANS endpoints answer <1s from a workstation but cf ssh is disabled on PROD so container egress couldn't be probed directly) makes svc.raise() block forever: it neither resolves nor throws. The existing fail-open try/catch in alerting.js is powerless against an unresolved promise, so the srv worker held the socket ~86s until CF dropped it → 502.

Fix (consumer stopgap)

raiseWithTimeout() races every raise against a 5s deadline:

  • raise() (production hooks) — swallows the timeout, unchanged fail-open contract.
  • raiseTest() (admin action) — returns outcome: 'timeout' with a clear reason, so the admin UI shows what happened instead of a 502.

outcome: String in the CDS return type is free-form, so 'timeout' flows through the existing handler untouched.

Tests

2 new unit tests (fake timers): a never-resolving raise yields outcome:'timeout' in raiseTest, and raise() returns cleanly without hanging. Full alerting suite 13/13, admin-send-test-alert 5/5.

Follow-up

Companion plugin fix adds an AbortController timeout inside ans-client.js (v1.0.2, separate PR) as belt-and-braces. Note: even with both timeouts, if CF→ANS egress is genuinely blocked, alerts fail fast and clean rather than delivering — that's a separate BTP networking question this fix stops masking.

…t 502

The ANS sink (@sap-tutorials/cds-alert-notification) delivers via a raw
fetch with no client-side timeout. A hung ANS connection (e.g. blocked CF
egress) makes svc.raise() block forever — neither resolving nor throwing —
so the existing fail-open try/catch is powerless. In PROD this held the srv
worker ~86s until CF dropped the socket, surfacing as a 502 Gateway Timeout
on the admin 'Send test alert'.

raiseWithTimeout() races every raise against a 5s deadline. A stuck delivery
now fails fast: raise() swallows it (unchanged fail-open contract), and
raiseTest() returns outcome:'timeout' with a clear reason so the admin sees
what happened. Belt-and-braces with the AbortController timeout added
plugin-side (v1.0.2).
@jung-thomas
jung-thomas merged commit fce45d2 into main Aug 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant