Skip to content

[Bug] nanocoder logs buffers the entire log file into memory #1042

Closed

Description

@akramcodez

Description

The logs() command in the daemon CLI is designed to return the last 64KB of the background daemon log. However, to do this, it calls fs.readFile() on the entire file, pulling hundreds of megabytes into memory just to run .slice(start) on it.

Environment

  • OS: Any
  • Node version: Node 18+
  • Nanocoder version: 1.30.0

Steps to Reproduce

  1. Let the daemon run for a long time until the log file is 1GB.
  2. Run the command to fetch logs.
  3. The Node process will attempt to allocate 1GB of heap memory and crash/stall.

Expected Behavior

The command should stream only the tail end of the file.

Actual Behavior

readFile(logPath, 'utf-8') buffers the whole file into RAM.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder

Implementation Notes

Fix in source/daemon/cli.ts:251-253. Use fs.createReadStream(logPath, { start }) or child process tail -c 65536.

Activity

  1. added
    bug
    performance
    on Aug 29, 2026
  2. AniketR10 commented on Aug 30, 2026

    @AniketR10
    Contributor

    @akramcodez please assign me this.

  3. added a commit that references this issue on Aug 30, 2026
    8998305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugperformance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions