[GH-ISSUE #7445] Exporting a very long chat freezes the server for seconds #4148

Closed
opened 2026-10-21 06:11:43 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7445

Originally assigned to: @SpicyMarinara on GitHub.

Problem

Exporting a very long chat freezes the whole server while the export is built. Other tabs, other users and live generation streams get no answer until it finishes.

Measured over real HTTP against staging with GET /api/chats/:id/export?format=jsonl:

  • 3,000 messages: about 1 s.
  • 12,000 messages: about 20 s, so the time grows roughly with the square of the message count.

A concurrent ping waited the whole 20 s, so the event loop never yielded. The result is the same with or without compression, which adds only about 0.2 s.

Likely cause (traced, not profiled)

serializeChatTranscript (packages/server/src/routes/chats.routes.ts, around line 4752, with the same pattern near line 5052) awaits storage.getSwipes(msg.id) once per message. That runs a filtered select on the file-backed store each time. The store resolves without real I/O, so the awaits never let other work run. A batch helper already exists: listSwipesByMessageIds in services/storage/chats.storage.ts.

Expected

An export of any size doesn't block other requests for more than a moment. Read the swipes in one batch, and if needed yield between chunks.

Found while verifying #7441 / #7444.

Originally created by @SpicyMarinara on GitHub (Oct 11, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7445 Originally assigned to: @SpicyMarinara on GitHub. ## Problem Exporting a very long chat freezes the whole server while the export is built. Other tabs, other users and live generation streams get no answer until it finishes. Measured over real HTTP against staging with `GET /api/chats/:id/export?format=jsonl`: - 3,000 messages: about 1 s. - 12,000 messages: about 20 s, so the time grows roughly with the square of the message count. A concurrent ping waited the whole 20 s, so the event loop never yielded. The result is the same with or without compression, which adds only about 0.2 s. ## Likely cause (traced, not profiled) `serializeChatTranscript` (`packages/server/src/routes/chats.routes.ts`, around line 4752, with the same pattern near line 5052) awaits `storage.getSwipes(msg.id)` once per message. That runs a filtered select on the file-backed store each time. The store resolves without real I/O, so the awaits never let other work run. A batch helper already exists: `listSwipesByMessageIds` in `services/storage/chats.storage.ts`. ## Expected An export of any size doesn't block other requests for more than a moment. Read the swipes in one batch, and if needed yield between chunks. Found while verifying #7441 / #7444.
bsakaguchi 2026-10-21 06:11:43 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Oct 11, 2026):

Working on this in branch fix/chat-export-freeze (Claude Code agent for @SpicyMarinara).

<!-- gh-comment-id:6111391801 --> @SpicyMarinara commented on GitHub (Oct 11, 2026): Working on this in branch fix/chat-export-freeze (Claude Code agent for @SpicyMarinara).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4148
No description provided.