Skip to content

Conversation

@quadr
Copy link
Contributor

@quadr quadr commented Nov 26, 2025

Summary

This PR implements asynchronous import job processing with a background worker to improve the reliability and performance of account data imports (following accounts, lists, muted/blocked accounts, bookmarks). (#94)

Changes

  • Database schema: Added import_jobs and import_job_items tables to track import job status and individual item processing
  • Background worker: Implemented a polling-based worker (src/import/worker.ts) that processes pending import jobs with database locking (FOR UPDATE SKIP LOCKED) to prevent duplicate processing
  • Import processors: Added dedicated processors (src/import/processors.ts) for each import category
  • UI updates: Refactored the accounts settings page to use the new async import system with progress tracking

Benefits

  • Non-blocking: Large imports no longer block the HTTP request
  • Progress tracking: Users can see real-time progress of their imports
  • Error resilience: Individual item failures don't stop the entire import
  • Queue support: Multiple imports queue up and process sequentially
  • Multi-instance safe: Database locking prevents duplicate processing across multiple server instances

Test plan

Automated checks (passed):

  • Type checking (pnpm check)
  • Linting (Biome)

Manual verification needed:

  • Database migration applies without errors
  • Import following accounts from CSV
  • Import lists from CSV
  • Import muted accounts
  • Import blocked accounts
  • Import bookmarks
  • Progress updates display correctly in UI
  • Multiple imports queue correctly
  • Failed individual items don't break entire import

quadr and others added 2 commits November 26, 2025 11:21
This fixes fedify-dev#94 where importing follows would block the server.

Changes:
- Add database tables for import jobs and items with status tracking
- Create background worker that polls for pending jobs every 5 seconds
- Process imports in batches with concurrency control (batch 10, concurrent 5)
- Add progress tracking UI with auto-refresh
- Support job cancellation for in-progress imports
- Graceful shutdown handling for the import worker

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Use FOR UPDATE SKIP LOCKED to ensure multiple worker instances
don't process the same import job or items concurrently.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@quadr quadr force-pushed the feature/async-import-jobs branch from f69104f to 45db26c Compare November 26, 2025 02:22
@dahlia dahlia added the enhancement New feature or request label Nov 26, 2025
@dahlia dahlia added this to the Hollo 0.7 milestone Nov 26, 2025
dahlia and others added 2 commits November 26, 2025 23:46
Replace raw SQL `ANY(${itemIds})` with Drizzle's `inArray()` function.
The raw SQL was incorrectly generating `ANY(($3, $4, ...))` which
PostgreSQL rejects as invalid syntax (error 42809). The `inArray()`
function properly generates an `IN` clause.

Co-Authored-By: Claude <[email protected]>
Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! 👍 I fixed a small bug and added a changelog for this patch.

@dahlia dahlia merged commit d2e05ec into fedify-dev:main Nov 26, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants