SurfSense/surfsense_backend/app
Matt Van Horn 456dd7417c
fix(connectors): refresh Redis heartbeat during long Phase 1 indexing
Closes #1295

The connector indexing route's `_run_indexing_with_notifications` set the
Redis heartbeat key once at the start of indexing and relied on
`on_heartbeat_callback` (only fired in Phase 2 per-document loops) to
refresh it. The GitHub connector's Phase 1 runs `gitingest` as a blocking
subprocess via `asyncio.to_thread`, so for any repo larger than the
2-minute TTL, the key expires before Phase 2 starts. The
`cleanup_stale_indexing_notifications_task` then marks the document as
failed with the misleading "Sync was interrupted unexpectedly. Please
retry." message — even though the indexing thread is still running and
gitingest's own subprocess timeout is 900 seconds.

Add a background asyncio coroutine that refreshes the Redis key every
60 seconds for the duration of the indexing call. Same pattern already
in use at app/tasks/celery_tasks/document_tasks.py:_run_heartbeat_loop,
just adapted to use the route's get_heartbeat_redis_client() and
_get_heartbeat_key() helpers.

Cancellation runs in the `finally` block BEFORE the heartbeat-key
delete so the loop cannot race and re-create the key after we have
deleted it. The new `HEARTBEAT_REFRESH_INTERVAL = 60` constant mirrors
the celery task module's value.
2026-04-26 02:46:43 -07:00
..
agents fix: delete broken sandbox before creating replacement to prevent orphan accumulation 2026-04-13 21:57:06 +02:00
config Merge remote-tracking branch 'upstream/dev' into feat/azure-ocr 2026-04-08 05:00:32 +05:30
connectors Make Vision LLM opt-in for uploads and connectors 2026-04-10 16:45:51 +02:00
etl_pipeline Merge upstream/dev into feat/kb-export-and-folder-upload 2026-04-11 10:28:40 +02:00
indexing_pipeline feat: add folder_id support in ConnectorDocument and indexing pipeline for improved document organization 2026-04-08 17:48:50 +05:30
prompts Simplify prompts to seed-based CRUD with version tracking 2026-03-31 18:05:42 +02:00
retriever feat: made agent file sytem optimized 2026-03-28 16:39:46 -07:00
routes fix(connectors): refresh Redis heartbeat during long Phase 1 indexing 2026-04-26 02:46:43 -07:00
schemas Merge upstream/dev into feat/kb-export-and-folder-upload 2026-04-11 10:28:40 +02:00
services Make Vision LLM opt-in for uploads and connectors 2026-04-10 16:45:51 +02:00
tasks Merge upstream/dev into feat/kb-export-and-folder-upload 2026-04-11 10:28:40 +02:00
templates feat: update report generation and export capabilities to support multiple formats (PDF, DOCX, HTML, LaTeX, EPUB, ODT, plain text) across documentation and backend 2026-03-09 18:41:21 -07:00
utils Route uploaded images to vision LLM with document-parser fallback 2026-04-09 14:33:33 +02:00
__init__.py feat: SurfSense v0.0.6 init 2025-03-14 18:53:14 -07:00
app.py Initialize vision LLM router at app and celery startup 2026-04-07 19:21:10 +02:00
celery_app.py Initialize vision LLM router at app and celery startup 2026-04-07 19:21:10 +02:00
db.py Merge upstream/dev into feat/kb-export-and-folder-upload 2026-04-11 10:28:40 +02:00
users.py Seed default prompts on registration and for existing users 2026-03-31 18:12:09 +02:00