Page MenuHomePhabricator

hCaptcha: Adjust tolerance of intermittent network errors
Closed, ResolvedPublic

Description

Summary

In T404204: Investigate options for automatic fallback to FancyCAPTCHA, we implemented a failover mode to load FancyCaptcha in the event that hCaptcha is unreachable. For reasons that are still being investigated, there are intermittent connection errors to load secure-api.js for outbound network calls (see https://logstash.wikimedia.org/goto/3638725468dcb59bc3e917335776afa1 for other examples). We currently set "failover mode" if secure-api.js is unreachable. We should instead tolerate a certain number of errors per period of time.

Acceptance criteria

  • the health checker implementation is reworked to accept a threshold of errors per window of time

Event Timeline

Change #1237732 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/ConfirmEdit@master] ConfirmEdit: Add error count threshold for apiUrl health checks

https://gerrit.wikimedia.org/r/1237732

Change #1237732 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] ConfirmEdit: Add error count threshold for apiUrl health checks

https://gerrit.wikimedia.org/r/1237732

Change #1238436 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/ConfirmEdit@wmf/1.46.0-wmf.14] ConfirmEdit: Add error count threshold for apiUrl health checks

https://gerrit.wikimedia.org/r/1238436

Change #1238436 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@wmf/1.46.0-wmf.14] ConfirmEdit: Add error count threshold for apiUrl health checks

https://gerrit.wikimedia.org/r/1238436

Mentioned in SAL (#wikimedia-operations) [2026-02-10T22:28:06Z] <kharlan@deploy2002> Started scap sync-world: Backport for [[gerrit:1238436|ConfirmEdit: Add error count threshold for apiUrl health checks (T416817)]]

Mentioned in SAL (#wikimedia-operations) [2026-02-10T22:32:20Z] <kharlan@deploy2002> kharlan: Backport for [[gerrit:1238436|ConfirmEdit: Add error count threshold for apiUrl health checks (T416817)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-02-10T22:40:40Z] <kharlan@deploy2002> Finished scap sync-world: Backport for [[gerrit:1238436|ConfirmEdit: Add error count threshold for apiUrl health checks (T416817)]] (duration: 12m 34s)

dom_walden subscribed.

Testing locally and setting $wgHCaptchaApiUrl = 'https://localhost' to simulate the hCaptcha service being down (note: I don't know if this is a realistic simulation).

When someone opens the edit page or Special:CreateAccount, we enter into the objectcache two variables: confirmedit-hcaptcha-available and confirmedit-hcaptcha-apiurl-error-count.

Serviceconfirmedit-hcaptcha-availableconfirmedit-hcaptcha-apiurl-error-countFailover?
Downtrue, expiry=30s1, expiry=30mNo
Down (third try)false, expiry=10m3+, expiry=unchangedYes
Down (...available has expired)false, expiry=10m3+, expiry=unchangedYes
Up (...available has expired)true, expiry=1mremovedNo
Down (...available and ...error-count has expired)true, expiry=30s1, expiry=30mNo

Notice in the last row, if the hCaptcha service is down for a prolonged period, every 30 minutes (when ...error-count expires) we leave failover mode for a couple of minutes while we wait for 3 failures to access the hCaptcha service.

kostajh claimed this task.