fix(alerting): hard timeout on ANS raise — admin test alert fails fast instead of 502 - #1505
Merged
Conversation
…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).
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 rawglobalThis.fetchwith no AbortController/timeout. A hung ANS connection (blocked CF egress is the prime suspect — both ANS endpoints answer <1s from a workstation butcf sshis disabled on PROD so container egress couldn't be probed directly) makessvc.raise()block forever: it neither resolves nor throws. The existing fail-opentry/catchinalerting.jsis 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) — returnsoutcome: 'timeout'with a clear reason, so the admin UI shows what happened instead of a 502.outcome: Stringin 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
raiseyieldsoutcome:'timeout'inraiseTest, andraise()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.