• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

archetech / archon / 30722346806

01 Aug 2026 10:56PM UTC coverage: 92.586% (+0.6%) from 91.941%
30722346806

Pull #825

github

macterra
fix(gatekeeper): cancel the save timer when stop() fails, and close the last coverage gaps

Covers the four files still at 0% after #822 exposed them: the gatekeeper
json and json-cache backends, the keymaster wallet cache, and the didcomm
service config. No file in the repo now sits below 60%.

Writing those tests found a resource leak in DbJsonCache.stop():

    async stop() {
        this.saveDb();                 // throws if the write fails
        if (this.saveLoopTimeoutId !== null) {
            clearTimeout(...);         // never reached
        }
    }

A gatekeeper on the json-cache backend with an unwritable database cannot
shut down: stop() throws, the 20-second save timer stays armed, and the
process never exits — a hung container until the orchestrator kills it.
Found the hard way, by a test that hung for 400 seconds.

Fixed with try/finally so the timer is always cancelled while the save
error still reaches the caller, plus a regression test asserting
saveLoopTimeoutId is null after a failed stop.

Two construction-time behaviours are now documented by test, both of
which contradicted my initial assumptions:

- The constructor writes a file. loadDb() falls into its catch on a
  missing file and immediately saves an empty database, so disk is
  touched before any explicit save.
- The constructor throws when the data folder cannot be created, rather
  than deferring to saveLoop's catch, because that save runs during
  construction.

Left alone but worth noting: DbJsonCache.loadDb() reads and parses the
file twice, assigning dbCache from one parse and then overwriting it with
another. Wasteful, not incorrect.

Repo total 95.19% -> 95.85%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Pull Request #825: fix(gatekeeper): cancel the save timer when stop() fails, and close the last coverage gaps

3482 of 4060 branches covered (85.76%)

Branch coverage included in aggregate %.

8157 of 8511 relevant lines covered (95.84%)

669.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.02
/packages/gatekeeper/src/db/json-cache.ts


Build SHA Not Found

The commit SHA "67754aabaa92383d95e84f425c51cb85267faf2d" was not found in your repository, so the file cannot be loaded. This may be because you posted from a local development environment, or your CI created an ephemeral commit.

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc