mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4629] [Issue]: Personal-extension runtime polled every 2s on every screen, in background tabs, even with zero extensions #2531
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#2531
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 @kolacheee on GitHub (Aug 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4629
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The personal-extension client runtime is polled over HTTP every 2 seconds, on every screen, for the whole app session — explicitly including hidden/background tabs — even when the user has zero extensions installed. On a phone this keeps the radio out of low-power state (~30 wakeups/minute); a Termux user pays the server side of every request too. Measured live on a built client: one
GET /api/personal-extensions/runtime/clientevery 2.0s (158 requests in 5.4 minutes), 302 B each, from a fresh install with no extensions.Expected behavior
Extension runtime freshness handled like the rest of the app's polling: visibility-gated, a modest interval (or none — mutation-driven invalidation already exists), and skipped entirely when there is nothing to poll for.
Actual behavior
usePersonalExtensionRuntime(packages/client/src/hooks/use-personal-extensions.ts:26-34) sets:with no
enabledgate. Its only consumer isPersonalExtensionInjector(packages/client/src/components/layout/PersonalExtensionInjector.tsx:386), mounted unconditionally at the App root (packages/client/src/App.tsx:1019) — so the poll runs on all screens for the app's lifetime.usePersonalExtensionPolicyadds a second poll every 10s (use-personal-extensions.ts:36-43). Each hit runsgetPersonalExtensionPolicy(db)+storage.list()server-side (packages/server/src/routes/personal-extensions.routes.ts:1153-1163).Notably this is the only poller in the client that sets
refetchIntervalInBackground: true— every other recurring poll is visibility-gated or background-disabled (ConversationPresenceCard.tsx:181,use-haptic.ts:16,use-noodle.ts:88), so backgrounded PWA tabs keep firing this one (subject only to browser timer throttling).Steps to reproduce
GET /api/personal-extensions/runtime/clientevery 2 seconds, indefinitely;GET /api/personal-extensions/policyevery 10 seconds.refetchIntervalInBackground: true), throttled only by the browser.Environment
93738d9b1)node packages/server/dist/index.js)Logs, screenshots, or video
Live measurement on the built client: 158 polls / 324 s uptime (avg gap 2,040 ms; last gaps 2017/2018/2013/2019/2014 ms), 302 B transfer each; confirmed still polling on the Chats screen via an instrumented fetch counter (5 polls / 12 s).
Additional context
Part of a mobile-battery investigation prompted by two user reports (phone heat in the browser client; baseline drain in Termux). This poll is a baseline cost with the app merely open and matches both reports; it predates the recent folder-access feature.
Suggested fix (matching the app's own conventions): drop
refetchIntervalInBackground: true; use a visibility-gated function-form interval (refetchInterval: () => (document.hidden ? false : 15_000)— theuse-haptic.ts:16pattern) or remove the interval and rely on the existing mutation invalidation (useInvalidatePersonalExtensions); optionally skip polling when the extension list is empty and external extensions are disabled.Related (same subsystem, server side, affects Termux installs with server extensions): the personal server-extension host communicates with child processes via file polling at 25 ms plus ~1 s heartbeat writes, continuously from boot. Happy to split that into its own issue if preferred.
Filed alongside #4628 (assistant streaming) and #4630 (Noodler reconcile scans).
Template check