Skip to content

fix(agent-source): stop buffered JSONL reads on cancellation - #661

Open
LIES225 wants to merge 1 commit into
MemTensor:mainfrom
LIES225:fix/abort-buffered-agent-history-reads
Open

LIES225 wants to merge 1 commit into
MemTensor:mainfrom
LIES225:fix/abort-buffered-agent-history-reads

Conversation

@LIES225

@LIES225 LIES225 commented Oct 19, 2026

Copy link
Copy Markdown

readJsonlObjects checks cancellation only when starting a new file chunk. If a caller aborts after reading the first of two JSONL rows in the same chunk, the next iteration still returns the buffered second row. A pre-aborted empty-file read also completes without an AbortError.

Check the existing abort signal before opening the stream, before processing each buffered record, and before parsing the final unterminated record. Preserve the existing AbortError and stream-cleanup behavior. This affects the shared reader used by Agent history import; it does not change persistence semantics or claim that higher-level scan cancellation writes extra memories.

Three real-file regressions cover buffered cancellation with/without a final newline and a pre-aborted empty file. Before the fix: 61 passed, 3 failed. After the fix:

  • npm test -w @memmy/agent-source-core: 64 passed.
  • npm run build -w @memmy/agent-source-core: passed.
  • npm run typecheck -w @memmy/agent-source-core: passed.
  • AgentSourceCore/node_modules/.bin/tsc -p AgentSourceCore/src/tests/tsconfig.json --noEmit: passed.
  • git diff --check: passed.

Validated on Windows with Node 24. Backend/Memory consumer integration suites and desktop/Electron builds were not run. No dependency or lockfile changes.

Implemented and tested with AI assistance.

@LIES225
LIES225 requested a review from ZongYue99 as a code owner October 19, 2026 03:57

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant