Skip to content

Markdown import reads every file with blocking std::fs::read_to_string inside async daemon tasks #2961

Closed

Description

@mstomar125

Problem

Running a large/slow markdown import — including the documented nodespace import dir ../nodespace-docs --auto-collection-routing workflow — can degrade concurrent daemon responsiveness (ai-chat streaming, WatchNodes delivery, other RPCs) for the duration of the import, because a blocking syscall run directly on a shared tokio worker thread prevents that worker from polling any other task until the read completes.

Root cause

import_single_file() (packages/daemon/src/services/import_service.rs:172) and the batch-import phase-1 loop in run_batch_import() (line 344) both call std::fs::read_to_string(path) directly inside async fns that run on the daemon's shared multi-threaded tokio runtime, with no spawn_blocking wrapper. Every other file-I/O call site in this crate (database_manager.rs, settings_service.rs) consistently uses tokio::fs, and this codebase has an established, explicitly-documented convention (assembly.rs, local_agent_service.rs) of wrapping slow synchronous work in spawn_blocking specifically to avoid parking a tokio worker thread — this file is the one outlier. run_batch_import's read loop is sequential, so the blocking reads happen one after another inside a single spawned task.

Suggested fix

Replace std::fs::read_to_string with tokio::fs::read_to_string (or wrap in spawn_blocking) in both import_single_file and run_batch_import's read loop, matching the crate's own established convention elsewhere.


Found via the 2026-09-25 full-repo code sweep (finding #11 of 84 in CODE_SWEEP_FINDINGS_2026-09-25.md). Severity: medium. Category: risky.

Activity

  1. self-assigned this
    on Sep 25, 2026
  2. added a commit that references this issue on Sep 28, 2026
    b273197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendsweepFound via the 2026-09-25 full-repo code sweep

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions