Skip to content

Crash on opening very large session files: Cannot create a string longer than 0x1fffffe8 characters #5231

@shekohex

Description

@shekohex

What happened?

I have a very large session file (+600MB) that I have a /goal running for days there, but for some reason I had to stop it to update my pi to latest version and when I tried to open it, it crashes with the following error: Error: Cannot create a string longer than 0x1fffffe8 characters

Full stacktrace:

$ pi -c
node:fs:440
    return binding.readFileUtf8(path, stringToFlags(options.flag));
                   ^

Error: Cannot create a string longer than 0x1fffffe8 characters
    at readFileSync (node:fs:440:20)
    at loadEntriesFromFile (file:///home/coder/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js:236:21)
    at SessionManager.setSessionFile (file:///home/coder/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js:517:32)
    at new SessionManager (file:///home/coder/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js:507:18)
    at SessionManager.continueRecent (file:///home/coder/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js:1075:20)
    at createSessionManager (file:///home/coder/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/dist/main.js:249:31)
    at main (file:///home/coder/.bun/install/global/node_modules/@earendil-works/pi-coding-agent/dist/main.js:435:32)
    at async file:///home/coder/.bun/install/global/node_modules/@shekohex/agent/dist/cli.js:7:1 {
  code: 'ERR_STRING_TOO_LONG'
}

Node.js v24.12.0

Steps to reproduce

That is a bit tricky, because you have to generate a 512+ MB Session file or at least the 0x1fffffe8 characters file! and try to open it, that is a limitation in Nodejs I assume? I have to dig more.

Expected behavior

I expect it to load the file, or at least we chunk it? since it is a JSONL after all, right? maybe we lazy load older entries? I know, large session files are uncommon, but I leave my agent running sometimes 24/7 on tasks that I throw at it. Happy to make a new PR.

Version

0.78.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginprogressIssue is being worked onpossibly-openclaw-clankerUser has activity on openclaw/openclaw

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions