Skip to content

[Bug] Invalid String Length #460

Description

@Jinkxed

Version. 15.9.1
MacOSX: Sequoia 15.6
Warp Terminal

Brand new installation never been ran. Installed via npm. Running ccusage returns the error.

ccusage

 WARN  Fetching latest model pricing from LiteLLM...                                   ccusage 11:27:13 PM

ℹ Loaded pricing for 1315 models                                                      ccusage 11:27:13 PM
node:internal/fs/promises:591
      result += decoder.write(readBuffer);
                        ^

RangeError: Invalid string length
    at readFileHandle (node:internal/fs/promises:591:25)
    at async loadDailyUsageData (file:///Users/chadupton/.asdf/installs/nodejs/22.17.0/lib/node_modules/ccusage/dist/data-loader-D3wQxjrt.js:3779:20)
    at async Object.run (file:///Users/chadupton/.asdf/installs/nodejs/22.17.0/lib/node_modules/ccusage/dist/index.js:4537:21)
    at async executeCommand (file:///Users/chadupton/.asdf/installs/nodejs/22.17.0/lib/node_modules/ccusage/dist/index.js:1122:2)
    at async cli (file:///Users/chadupton/.asdf/installs/nodejs/22.17.0/lib/node_modules/ccusage/dist/index.js:1034:2)
    at async file:///Users/chadupton/.asdf/installs/nodejs/22.17.0/lib/node_modules/ccusage/dist/index.js:5722:1

Node.js v22.17.0

Activity

  1. PaulRBerg commented on Sep 11, 2025

    @PaulRBerg

    Also getting this error in Warp and iTerm2

     WARN  Fetching latest model pricing from LiteLLM...                                                           ccusage 5:40:40 PM
    
    ℹ Loaded pricing for 1492 models                                                                              ccusage 5:40:40 PM
    np node:internal/fs/promises:586
          result += decoder.write(readBuffer);
                            ^
    
    RangeError: Invalid string length
        at readFileHandle (node:internal/fs/promises:586:25)
        at async loadDailyUsageData (file:///Users/prb/Library/Application%20Support/fnm/node-versions/v23.11.1/installation/lib/node_modules/ccusage/dist/data-loader-Plh5X-UR.js:2509:20)
        at async Object.run (file:///Users/prb/Library/Application%20Support/fnm/node-versions/v23.11.1/installation/lib/node_modules/ccusage/dist/index.js:3300:21)
        at async executeCommand (file:///Users/prb/Library/Application%20Support/fnm/node-versions/v23.11.1/installation/lib/node_modules/ccusage/dist/index.js:758:2)
        at async cli (file:///Users/prb/Library/Application%20Support/fnm/node-versions/v23.11.1/installation/lib/node_modules/ccusage/dist/index.js:679:2)
        at async file:///Users/prb/Library/Application%20Support/fnm/node-versions/v23.11.1/installation/lib/node_modules/ccusage/dist/index.js:4438:1
    
    Node.js v23.11.1
    

    Env:

    • ccusage 16.2.4
    • claude v1.0.111
  2. jsell-rh commented on Oct 18, 2025

    @jsell-rh
    npx [email protected]
    
     WARN  Fetching latest model pricing from LiteLLM...                                                                    ccusage 9:51:42 AM
    
    ℹ Loaded pricing for 1667 models                                                                                       ccusage 9:51:42 AM
    node:internal/fs/promises:585
          result += decoder.write(readBuffer);
                            ^
    
    RangeError: Invalid string length
        at readFileHandle (node:internal/fs/promises:585:25)
        at async loadDailyUsageData (file:///home/jsell/.npm/_npx/86ddde3d5ecc57c4/node_modules/ccusage/dist/data-loader-BGg_9orY.js:3557:19)
        at async Object.run (file:///home/jsell/.npm/_npx/86ddde3d5ecc57c4/node_modules/ccusage/dist/index.js:4506:21)
        at async executeCommand (file:///home/jsell/.npm/_npx/86ddde3d5ecc57c4/node_modules/ccusage/dist/index.js:881:2)
        at async cli (file:///home/jsell/.npm/_npx/86ddde3d5ecc57c4/node_modules/ccusage/dist/index.js:794:2)
        at async run (file:///home/jsell/.npm/_npx/86ddde3d5ecc57c4/node_modules/ccusage/dist/index.js:6391:2)
        at async file:///home/jsell/.npm/_npx/86ddde3d5ecc57c4/node_modules/ccusage/dist/index.js:6399:1
    
    Node.js v22.16.0

    Same issue on v17.1.3. I have a session file that is 585MB causing this error.

    Would love to see this fixed as large projects like this are most critical to keep tabs on costs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions