mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4703] [Issue]: Chat tab stuck fetching messages?limit=100 in an infinite loop, causing excessive network traffic #2578
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2578
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lattete on GitHub (Aug 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4703
Originally assigned to: @kolacheee on GitHub.
Summary
Opening a character chat causes the
messages?limit=100request to fire repeatedly in an infinite loop, transferring massive amounts of data (150+ requests, 150MB+ in a short window) while the tab is idle.Expected behavior
This endpoint should only be called once when the chat is opened (or on actual new messages), not repeatedly while idle.
Actual behavior
The
messages?limit=100endpoint is called repeatedly without stopping. In one ~1 minute window, DevTools showed 150+ calls to this endpoint, with individual response sizes ranging from ~228KB to 4.4MB, totaling over 150MB transferred. This continues as long as the chat tab stays open, and only stops when navigating away (e.g. to the Presets menu) and refreshing.Steps to reproduce
Environment
Logs, screenshots, or video
Before disabling Presence/Weather effects:

After disabling Presence/Weather effects (traffic got worse, not better — so these settings are likely not the actual cause):

Browser DevTools Network tab, filtered — showing the

messages?limit=100request firing repeatedly:Additional context
"Impact:" On mobile data, this used roughly 6GB of data in under an hour before I noticed and killed the process.
Note: the transfer rate actually increased after I disabled the Presence indicator and Weather effect features, ruling those out as the direct cause.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Aug 7, 2026):
@Lattete thank you for submitting this issue! I will take a look at it.
@kolacheee commented on GitHub (Aug 7, 2026):
Triage note: this is mechanically distinct from #4704 (which covers the designed 30-second background-autonomous poll of the chat list). What you're seeing —
messages?limit=100at 150+/minute — matches no designed poll in the codebase (the messages query has no refetch interval; all its invalidations are event-driven), so this looks like a runaway invalidation/refetch feedback loop, likely response-latency-bound (~400ms period ≈ the round-trip time for MB-scale payloads over Tailscale). Root-cause investigation is underway; will follow up here with the mechanism and whether current staging is affected. The excellent evidence in this report (request rate, response sizes, the presence/weather rule-out) is what makes that tractable — thank you.@kolacheee commented on GitHub (Aug 7, 2026):
Root-cause investigation results (traced on both v2.4.1 and current staging; verified against the installed React Query source).
Confirmed: the amplifier that makes 150MB/min possible
The chat's message list is an infinite query (
useChatMessages,use-chats.ts:269-293) that accumulates one cached page per "Load More". React Query v5 refetches an infinite query by re-fetching every accumulated page sequentially, each request issued the instant the previous response completes (verified in@tanstack/query-core@5.100.9infiniteQueryBehavior.js— a zero-delaydo/whileoveroldPages.length). So any single refetch trigger = N back-to-backmessages?limit=100[&before=...]requests at wire speed — your ~400ms cadence is the network round-trip for MB payloads over Tailscale, not a timer. This also explains why only refreshing stopped it: a refresh resets the page cache to one page (and on mobile, navigating to another panel keeps the chat mounted underneath —AppShelloverlay mode — so the query observer never unmounts). Mechanism unchanged between v2.4.1 and staging.The sustained trigger: three real candidates, not yet proven
What re-triggers the storm continuously needs one data point from your setup to discriminate:
refetchOnReconnect— the messages query inherits React Query's defaultrefetchOnReconnect: true(only window-focus refetch is globally disabled), with a 30s stale time. Mobile + VPN = frequentonlineevents; each one after 30s = a full-pages storm.generation_discardedcase where you'd see nothing happen at all) ends in an authoritative refetch of all pages.refetchType: 'all'in the Mari workspace path can walk inactive per-chat message pages too.Could you check: (a) is Messages-per-page set to 100 in your settings, and had you scrolled far back in that chat's history before it started (roughly how many "Load More"s)? (b) does the affected chat have autonomous messages enabled? (c) in the DevTools capture, do the repeated requests carry
&before=cursors (a storm re-walking pages) or always the bare?limit=100(restarting storms)? A HAR of ~2 minutes would settle it completely.Fix direction
The amplifier should be fixed regardless of which driver is live, because it converts any stray refetch into a megabyte storm: bound the page cache (
maxPages) on the messages query, overriderefetchOnReconnectfor it, and make the authoritative refreshes target'active'+ coalesce per chat. That turns the worst case from 150MB/min into a single cheap page fetch — then the surviving driver (if any) becomes visible and small enough to fix on its own.@Lattete commented on GitHub (Aug 7, 2026):
Here are the details regarding your questions:
(a) Messages-per-page & Scroll history:
The chatroom where this occurred was a Roleplay (RP) chat.
My Messages-per-page setting is currently set to 20.
I never clicked "Load More" and only viewed the already rendered messages (scrolled up at most 5–6 turns).
(b) Autonomous messages:
Yes, Autonomous messages are enabled (ON) for this chat.
(c) Request URL patterns:
Checking the repeated message request URLs, only '?limit=100' is repeating. There is no '&before='cursor present.
Since the HAR file is over 200MB and exceeds GitHub's file size limit, I'm sharing it via Google Drive instead:
https://drive.google.com/file/d/1c5NkqHRRdAOiDZGY0iD2mcPRplTp92_N/view?usp=drive_link
Hope this helps narrow down the cause!
@kolacheee commented on GitHub (Aug 7, 2026):
Thank you for the HAR — it identified the source definitively, and it's not what any of us guessed. The requests are not coming from Marinara's own UI. They're coming from an installed personal extension.
What the HAR shows
Your capture spans 125.5 seconds and contains 448 requests, of which 426 are
GET /api/chats/<id>/messages?limit=100(≈204/min). The key detail: those 426 requests are not for one chat — they cycle through 18 distinct chat ids, round-robin. The traffic is organized into 24 complete sweeps:GET /api/chatsplusGET+PATCH /api/personal-extensions/taB-MN2qBdEec0hn827Va/storage.That last endpoint is the smoking gun:
personal-extensions/…/storageis the persistence API for user-installed personal extensions. Nothing in Marinara's core client ever enumerates every chat and downloads each one's messages — but an extension script running in your session is doing exactly that, continuously, with a hardcodedlimit=100(which is why the URL never matched your messages-per-page setting of 20, and why there's never abefore=cursor).The extension's storage payload structure (field names only — I did not read your data) is:
So it appears to be a memo / notes-board extension. It rescans the full message history of every chat on every pass, which on your instance moves roughly 1 MB per request — matching the multi-GB/hour traffic you measured. This would also account for a good share of the battery drain on the Termux host, since the server has to serve those ~200 reads/min.
What to do
messages?limit=100stream should be gone entirely.Engine-side follow-ups
This also exposes real engine work, which I'm handling separately:
RP mode and autonomous messages turned out to be coincidental — the sweep runs regardless of which chat is open.
@Lattete commented on GitHub (Aug 7, 2026):
As you mentioned, I do use the memo extension.
Right after reading your message, I disabled it, but the issue persisted.
So I turned off all other extensions and tested them one by one to narrow it down.
It turns out the real culprit was a completely different extension.
It wasn't the memo extension, but a receipt extension that reads chat message tokens to calculate the total cost.
I'm not sure why it was logged as 'memoData' in the storage, but my tests confirmed this was the one causing the network spam.
Thanks to your advice, I was able to find the root cause. I've disabled the problem extension, and the issue has completely stopped.
The extension is called 'Marinara Token Cost Receipt v2.0.0' and is also available on GitHub.
I will try to reach out to the developer of that extension to let them know.
Thank you so much for reviewing my issue so quickly!
@kolacheee commented on GitHub (Aug 7, 2026):
@Lattete of course, thank you for the quick and comprehensive replies, it made troubleshooting the problem so much easier 🙂 I will be closing this Issue now.