Repository navigation
fix(platform): pause website scans when the knowledge db is unreachable - #3049
Merged
Merged
Conversation
A scheduled crawl of an org with a bring-your-own knowledge database
acquired its corpus pool before the try block, so a connection-class
failure (rotated credential, DNS, refused) escaped the action uncaught,
and the catch recorded the failure into the same unreachable Postgres.
Nothing ever reached the Convex websites row, so the five-minute
scheduler re-queued the domain forever — three weeks of silent 2-hourly
failures on demo.tale.dev (GlitchTip TALE-PROJECT-106, 234 events).
- classify connection-class errors in knowledge/pool.ts
(isConnectionFailure) and catch them around pool acquisition and all
corpus SQL in scanWebsite
- record failed attempts on the Convex websites row — the only store
still reachable — and surface the error in the websites UI
- back failed scans off to a bounded retry window and pause the site
after 3 consecutive connection failures (websites/scan_scheduling.ts)
- notify org admins once per incident via the notifications bell
("check Settings → Data residency"), mirrored for the Slack sink
- add a Paused badge and a "Resume scanning" row action that clears
the pause and kicks a verification scan
larryro
force-pushed
the
fix/crawler-pause-on-unreachable-corpus
branch
from
August 23, 2026 09:36
80aa8f8 to
f489cbe
Compare
The jsdom suite mocks ../hooks/mutations with an explicit factory, so the new useResumeScanning hook made WebsiteRowActions throw "no export defined on the mock" and failed the UI job. Add the hook to the mock and, while here, lock the new behaviour: the resume item appears only while the crawler has paused the site, and clicking it calls the action with the row's websiteId.
main now ships a first-party analytics tag loading /_a/script.js, a path only the web droplet's Caddy proxy answers in production. Vite's dev and preview servers have no such upstream, so every page 404s the script into the browser console and the smoke suite's no-console-errors guard fails — latent on main (change detection skips the web suite there) and surfacing on any PR whose merge ref includes it. Serve a no-op stub on exactly that path in both servers; the built artifact stays untouched, so a broken droplet proxy still fails loudly in production.
larryro
force-pushed
the
fix/crawler-pause-on-unreachable-corpus
branch
from
August 23, 2026 11:59
ca42e25 to
9189d50
Compare
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.
Fixes the endless-retry loop behind TALE-PROJECT-106 —
Uncaught PostgresError: password authentication failed for user 'neondb_owner', 234 events, 2026-08-01 → 2026-08-21, ~one every 2 h,userCount: 0(pure background cron on demo.tale.dev).Problem
scanWebsiteacquired the org corpus pool before itstryblock. For a bring-your-own database,getKnowledgePoolForOrgruns real SQL (the corpus-schema bootstrap), so an invalid credential threw right there and escaped the action uncaught. Thecatchthen recordedstatus = 'error'into the same unreachable Postgres, so when the database itself was down nothing was recorded anywhere. The Convexwebsitesrow never advanced its clock, and the five-minute scheduler re-queued the domain forever — no backoff, no cap, no admin-facing signal.Fix
isConnectionFailureinknowledge/pool.ts: SQLSTATE classes 08/28,3D000,57P03, postgres.js lifecycle codes (CONNECT_TIMEOUT,CONNECTION_CLOSED, …), Node system errors (ENOTFOUND,ECONNREFUSED, …).websitesrow (recordScanFailure), the only store still reachable; reachable-but-failed scans keep marking the corpus and now also stamp the Convex row.metadata.lastScanAttemptAt; the scheduler (pure policy inwebsites/scan_scheduling.ts, unit-tested) retries failing sites onmin(interval, 2 h)instead of every tick.metadata.scanPausedAt) and the org's admins get a one-per-incident bell notification (securitycategory, Slack-mirrored): "Check the connection under Settings → Data residency, then resume scanning from the Websites page."NOTIFICATIONS_I18Nfor the Slack sink, and registered inkeys-dynamic.yml(server-emitted keys are invisible to the client-source scanner).The failure bookkeeping lives in
websites.metadata— no schema change, no migration.Tests
pool.test.ts— classifier: unreachable vs statement-level SQLSTATEs (an FK violation like the Jul 18website_urlsincident stays statement-level).scan_scheduling.test.ts— the regression: a failing site is not re-queued on the next tick; bounded failure retry (a 30-day site retries in 2 h, an hourly site stays hourly); paused sites are never due; stuck-scanningtakeover unchanged and re-armed by failed attempts.record_scan_failure.test.ts(convex-test) — streak counting, pause at the threshold with exactly one notification, no re-notify while paused, streak reset on reachable-but-failed scans,clearScanFailures, and the scheduler projection.Observed: 416 tests green across
convex/websites,convex/knowledge,convex/notifications,lib/i18n;tsc --noEmitclean;oxlint --type-awareclean over the touched dirs.Ops follow-up (not in this PR)
The demo org's Neon credential (
neondb_owner) is still invalid — last failure 2026-08-21. Rotate/fix it under Settings → Data residency, then hit Resume scanning on the site. The GlitchTip issue should stay open until this ships and the credential is fixed.CI fixes (reviewer: "fix all ci action errors")
website-row-actions.test.tsx(existing jsdom suite) mocks../hooks/mutationswith an explicit factory, so the newuseResumeScanninghook threw "no export defined on the mock". Fixed by extending the mock and locking the new behaviour: the resume item appears only while the site is paused, and clicking it calls the action with the row'swebsiteId. Fulltest:uisuite verified locally (434 files / 3338 tests green); the UI job passed on the next CI round.main, not from this PR:500eaa3e8added a first-party analytics tag loading/_a/script.js, a path only the web droplet's Caddy proxy answers in production. Vite's dev/preview servers 404 it, tripping the smoke suite's no-console-errors guard — latent onmainbecause change detection skips the web suite there, surfacing on any PR whose merge ref includes it. Fixed here (fix(web)commit) with a no-op stub served by vite dev/preview only; the built artifact is untouched, and thetale-web:release-feeddev route is preserved. Web smoke suite verified locally against a build carrying the analytics tag. Maintainers may prefer to cherry-pick that one commit straight tomain, since every open PR that touches web paths will hit the same failure.