The watchdog is a package now, not a file in this repo - #80
Merged
Merged
Conversation
Shipped here yesterday as apps/web/src/lib/db-watchdog.js, and genrewatch and watchnews both need the same thing for the same reason, so it is @profullstack/watchdog 0.2.0 instead of three copies. What moved is not really the code, it is the reasoning. Why the probe has to go through the SAME client the requests use, why the timeout has to be a race rather than a driver option, and why Redis is allowed one more failure than the pool because a healthy Redis is routinely unreachable while it reloads its snapshot. A comment explaining that is worth nothing if it only exists in one of three copies, and the numbers drift apart the moment they are duplicated. `watchDependencies` takes probes rather than clients, so the package stays zero-dependency and does not care that this repo is on bun:sql and ioredis. The DB_WATCHDOG and REDIS_WATCHDOG knobs and their defaults live there too, so this file no longer names any of them. Net 38 lines lighter here, and the module's own tests moved to the package. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Shipped here yesterday in #79 as
apps/web/src/lib/db-watchdog.js. genrewatch andwatchnews both need the same thing for the same reason, so it is now
@profullstack/watchdog 0.2.0
instead of three copies.
Why a package rather than a copy
What is worth sharing is not the code, it is the reasoning:
connection is the one thing guaranteed to look healthy during this failure
that never settles
unreachable while it reloads its snapshot (26s at 1.8GB, 124s at the 8.65GB that caused
The live tick was storing every synced row in Redis, sixty times an hour #78)
A comment explaining that is worth nothing if it lives in one of three copies, and the
numbers drift apart the moment they are duplicated.
What changes here
watchDependenciestakes probes rather than clients, so the package stayszero-dependency and does not care that this repo is on
bun:sqlandioredis. TheDB_WATCHDOG_*andREDIS_WATCHDOG_*knobs and their defaults live there now, so thisfile no longer names any of them.
apps/web/src/lib/db-watchdog.jsdeletedtest/db-watchdog.test.jsdeleted, the module's 19 tests live in the package@profullstack/watchdogadded toapps/web/package.json, beside the other@profullstackapp dependenciesBehaviour is unchanged: same probes, same timings, same one-extra-failure for Redis.
Testing
bun installresolves 0.2.0,bun build apps/web/src/main.jsbundles clean (which is whatactually proves the new import resolves),
biome checkclean, and 39 pass / 0 fail acrossconfig, nichedb-plays and odds-archive.
The package itself is 19 tests, zero dependencies, no build step.
Note
apps/worker/src/main.jsis the alternate entry for splitting workers onto their ownservice, and it has no watchdog. It is not the deployed shape (the default runs web+worker
in one container via
apps/web), so I left it alone rather than widen this.🤖 Generated with Claude Code