Skip to content

test(e2e): name DMS auth as the cause of the health route's 500 with MongoDB down - #222

Merged
Upd4ting merged 1 commit into
mainfrom
fix/wdf26acfc-150
Nov 19, 2026
Merged

Upd4ting merged 1 commit into
mainfrom
fix/wdf26acfc-150

Conversation

@Upd4ting

Copy link
Copy Markdown
Member

Why

Wdf26acfc-150. With MongoDB down, the Overview should report the connection as down within the probe's 3 s deadline. Today GET /api/database/health answers 500 after 30 s. The journey's knownFailures entry blamed getOverviewHealth for reading totals after a failed probe. A run with a log at the route's entry shows the route never runs: DMS auth fails first.

What changes

The knownFailures reason of an-unreachable-database-shows-unavailable-and-check-again-recovers in e2e/journeys/overview.mjs now names the real cause. @AuthOwnerOnly / @AuthRawUser of @antelopejs/dms 0.21.2 (validateUserToken) reads the session (loadTokenSession) and records the user's activity (recordUserActivity) in MongoDB on every request. With MongoDB stopped, both wait for the driver's 30 s server selection and the request answers 500 before dms-database's route is entered. No source change: nothing in this repo can make an authenticated route answer while the DMS's own database is down.

sequenceDiagram
  participant Page as Overview page
  participant Auth as DMS auth (validateUserToken)
  participant Mongo as MongoDB (stopped)
  participant Route as dms-database /api/database/health
  Page->>Auth: GET /api/database/health
  Auth->>Mongo: loadTokenSession / recordUserActivity
  Mongo--xAuth: ECONNREFUSED after 30 s server selection
  Auth-->>Page: 500 (Route never runs)
  Note over Route: getOverviewHealth and its 3 s probe are not reached
Loading

Proof

Journey run on origin/main (c620351) with its knownFailures entry removed:

Error: the health route answers status down within 10 s of the request: {"status":500,"body":null,"ms":30010}

Same run with getOverviewHealth returning at once on a down probe: unchanged, so that code is not on the failing path.

Error: the health route answers status down within 10 s of the request: {"status":500,"body":null,"ms":30011}

Same run with a temporary console.warn("WDF150 route entered") at the route's entry. The two 500s, logged while MongoDB was stopped, have no entry line before them. The entry lines come from before the stop and after the restart:

WDF150 route entered 1795124713314
WDF150 selected resolved 1795124713322
WDF150 route entered 1795124713741
WDF150 selected resolved 1795124713741
[2026-11-19 21:46:14] [ERROR] HTTP 500 GET /api/database/health: connect ECONNREFUSED 127.0.0.1:37245
[2026-11-19 21:46:44] [ERROR] HTTP 500 GET /api/database/health: connect ECONNREFUSED 127.0.0.1:37245
WDF150 route entered 1795124804885
WDF150 selected resolved 1795124804885

After this change (entry kept, reason rewritten), pnpm e2e:run specs/overview.spec.ts -g unreachable --workers=1:

  ✓  1 [chromium] › e2e/fixtures.ts:69:7 › overview › an-unreachable-database-shows-unavailable-and-check-again-recovers (1.6m)

  1 passed (1.7m)

Follow-ups

  • proposed AntelopeJS/dms: with its own database down, an authenticated request answers 500 after 30 s because validateUserToken reads and writes MongoDB per request, done means it fails within a few seconds with a 503 the dashboard can show
  • proposed AntelopeJS/dms-database: with an external connection down and the own database up, getOverviewHealth still lists schema summaries and row counts after a failed probe, so GET /api/database/health waits for the driver's timeout and the unguarded sampleRows throws a 500; done means it answers status: down with the probe's error within the 3 s deadline, proven by a test on a down external connection (needs a fixture this repo lacks today: a stoppable second MongoDB, or a provider on a closed port)

@Upd4ting
Upd4ting marked this pull request as ready for review November 19, 2026 21:51
@Upd4ting
Upd4ting added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 64dd3e6 Nov 19, 2026
13 of 21 checks passed
@Upd4ting
Upd4ting deleted the fix/wdf26acfc-150 branch November 19, 2026 22:32
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