[GH-ISSUE #7260] [Issue]: Backgrounding the tab terminates client extension workers #4052

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

When the Marinara Engine tab is backgrounded for about 10 seconds, browser timer throttling stalls the client extension heartbeat and the watchdog terminates an otherwise healthy worker. The extension panel still renders from cached registration, but all controls stop responding without console errors.

Expected behavior

Client extension workers should remain usable after the tab is backgrounded and restored, or the watchdog should account for background-tab timer throttling before terminating the worker.

Actual behavior

After returning to the tab, the client extension panel renders but every control is unresponsive because the worker was terminated while hidden. No console errors are visible.

Steps to reproduce

  1. Load Marinara Engine and open a client extension panel.
  2. Verify that the panel buttons or controls work.
  3. Switch to another browser tab for approximately 10 seconds or longer.
  4. Return to the Marinara Engine tab.
  5. Click the client extension controls and observe that they no longer respond.

Environment

  • Marinara Engine version: 2.5.0 (build 2.5.0+7e28236962a0, commit 7e28236962)
  • Install type: Not provided in Discord context.
  • OS + version: macOS 10.15.7 according to diagnostics; reporter notes the device is Apple Silicon
  • Browser or app shell: Safari 27.0.1

Logs, screenshots, or video

No screenshots or video provided. Support diagnostics were provided. No console errors were observed. Suspected runtime code is served by GET /personal-extensions/runtime/client: the worker sends heartbeats every 1 second, while the watchdog terminates it after more than 5 seconds without a heartbeat. The watchdog reports an unresponsive-worker error while the tab is hidden, so users do not see it.

Additional context

Reproduced consistently. The issue was also present in the previous release, where the watchdog code was reportedly identical. The extension remains enabled and its hashes remain unchanged, suggesting a runtime lifecycle issue rather than permissions or approval. The proposed fix is to pause or relax the watchdog while document.hidden, or reset lastHeartbeat when visibility changes back to visible. Workaround: reload the app and avoid leaving the tab backgrounded for more than approximately 5 seconds. A separate minor issue was reported where the top-bar client extension button may be missing after a fresh load until a remount.

Discord thread: Client extensions: background tab kills worker — panel renders, buttons dead
Discord thread link: https://discord.com/channels/1417099416812392641/1557462067101958246
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (4 messages)
[2026-10-07T18:38:13.043Z] spacyH: (Report written by Prof. Mari on Deepseek 4.1 Flash)

**TL;DR: **Client extensions run in a hidden sandboxed iframe; the worker heartbeats every 1s and a watchdog kills it after 5s of silence. Background the tab → timers throttle → heartbeat stalls while the clock runs → healthy worker killed while user is away. Panel still renders (cached registration), every click posts into the void, zero console errors.

**Env: **Marinara Engine, latest release as of 2026-10-07 (also in previous release; watchdog code identical). Safari/macOS; any browser with background-tab throttling likely affected. Any runtime: client extension.

**Repro (100%):** 
1. Load app, open a client extension panel — buttons work. 
2. Switch tab ~10+ s. 
3. Return: panel renders, every control dead, console clean.

**Root cause** — sandbox bootstrap served by `GET /personal-extensions/runtime/client` (`packages/server/dist/routes/personal-extensions.routes.js`):
L697: `self.setInterval(() => send({ type: "heartbeat" }), 1_000);`
L1002–1008 watchdog: `if (stopped || Date.now() - lastHeartbeat <= 5_000) return; stopped = true; worker.terminate();` then posts the "unresponsive" error
`lastHeartbeat` advances only on heartbeats; no `visibilitychange` handling in the file (grep-verified). The error fires while the tab is hidden — users never see it.
Not permissions/approval: record stays enabled, hashes match throughout — purely runtime.

**Fix (small):** on `visibilitychange` → visible, reset `lastHeartbeat = Date.now();` and/or raise the threshold (e.g. 90s) or pause the watchdog while `document.hidden`. Hung workers still get caught.

**Related minor bug:** top-bar button often missing on fresh load until a remount (tab switch) — client polls the runtime endpoint with a 30s staleTime.

**Workaround:** after reloading the app, don't linger in other tabs (<5s), or reload for a fresh worker.
[Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462067101958246]

[2026-10-07T18:38:13.698Z] Professor Mari [bot]: Howdy!

Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.**

**Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab:

`Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.`

If your report is about any of the **Agents**, please provide **the Agent's version** which you can grab from here:

`Agents -> Download Agents -> Installed Agents -> Selected Agent -> Installed Version`

Thank you, this will help tremendously.

This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case.

Cheers!
[Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462069849362546]

[2026-10-07T18:38:30.099Z] spacyH: ` ` `
Marinara Engine diagnostics
Version: 2.5.0
Build: 2.5.0+7e28236962a0
Commit: 7e28236962a0
Server OS: Linux 7.0.14-orbstack-00380-ga7e0a2dc9535 (arm64)
Server memory: heap 160.7 / 2240 MiB; RSS 283.3 MiB
Background wake lock: not reported
Last detected freeze: ~2180s suspension, thawed at 2026-10-07T17:47:08.285Z
Previous session: shut down cleanly at 2026-10-07T07:19:58.289Z
Sessions ended without shutdown: 2 recorded
Client OS: macOS 10.15.7
Browser / app shell: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/27.0.1 Safari/605.1.15
Client runtime: {"build":"2.5.0+7e28236962a0","page":"muxs2gf4-6x61if99","persistence":"local","navigation":"navigate","standalone":false,"view":[810,0,0,0],"events":[]}
GPU: Apple GPU
Server GPU: no NVIDIA GPU detected
Main sidecar: not configured
Utility sidecar: not configured
Decision sidecar: not configured
Sidecar load: not measured
Active connection: Deepseek Flash
Connection provider: openai
LLM model: deepseek-flash
Mari last acted on: none recorded this session
` ` `
[Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462138640015451]

[2026-10-07T18:40:04.720Z] spacyH: Weird, don't know why the diagnostics say I'm on macOS 10.15.7 Intel - it's actually 27.0.1 Apple Silicon
[Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462535509250089]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Oct 7, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7260 Originally assigned to: @SpicyMarinara on GitHub. ## Summary When the Marinara Engine tab is backgrounded for about 10 seconds, browser timer throttling stalls the client extension heartbeat and the watchdog terminates an otherwise healthy worker. The extension panel still renders from cached registration, but all controls stop responding without console errors. ## Expected behavior Client extension workers should remain usable after the tab is backgrounded and restored, or the watchdog should account for background-tab timer throttling before terminating the worker. ## Actual behavior After returning to the tab, the client extension panel renders but every control is unresponsive because the worker was terminated while hidden. No console errors are visible. ## Steps to reproduce 1. Load Marinara Engine and open a client extension panel. 2. Verify that the panel buttons or controls work. 3. Switch to another browser tab for approximately 10 seconds or longer. 4. Return to the Marinara Engine tab. 5. Click the client extension controls and observe that they no longer respond. ## Environment - Marinara Engine version: 2.5.0 (build 2.5.0+7e28236962a0, commit 7e28236962a0) - Install type: Not provided in Discord context. - OS + version: macOS 10.15.7 according to diagnostics; reporter notes the device is Apple Silicon - Browser or app shell: Safari 27.0.1 ## Logs, screenshots, or video No screenshots or video provided. Support diagnostics were provided. No console errors were observed. Suspected runtime code is served by GET /personal-extensions/runtime/client: the worker sends heartbeats every 1 second, while the watchdog terminates it after more than 5 seconds without a heartbeat. The watchdog reports an unresponsive-worker error while the tab is hidden, so users do not see it. ## Additional context Reproduced consistently. The issue was also present in the previous release, where the watchdog code was reportedly identical. The extension remains enabled and its hashes remain unchanged, suggesting a runtime lifecycle issue rather than permissions or approval. The proposed fix is to pause or relax the watchdog while document.hidden, or reset lastHeartbeat when visibility changes back to visible. Workaround: reload the app and avoid leaving the tab backgrounded for more than approximately 5 seconds. A separate minor issue was reported where the top-bar client extension button may be missing after a fresh load until a remount. Discord thread: Client extensions: background tab kills worker — panel renders, buttons dead Discord thread link: https://discord.com/channels/1417099416812392641/1557462067101958246 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (4 messages)</summary> ```text [2026-10-07T18:38:13.043Z] spacyH: (Report written by Prof. Mari on Deepseek 4.1 Flash) **TL;DR: **Client extensions run in a hidden sandboxed iframe; the worker heartbeats every 1s and a watchdog kills it after 5s of silence. Background the tab → timers throttle → heartbeat stalls while the clock runs → healthy worker killed while user is away. Panel still renders (cached registration), every click posts into the void, zero console errors. **Env: **Marinara Engine, latest release as of 2026-10-07 (also in previous release; watchdog code identical). Safari/macOS; any browser with background-tab throttling likely affected. Any runtime: client extension. **Repro (100%):** 1. Load app, open a client extension panel — buttons work. 2. Switch tab ~10+ s. 3. Return: panel renders, every control dead, console clean. **Root cause** — sandbox bootstrap served by `GET /personal-extensions/runtime/client` (`packages/server/dist/routes/personal-extensions.routes.js`): L697: `self.setInterval(() => send({ type: "heartbeat" }), 1_000);` L1002–1008 watchdog: `if (stopped || Date.now() - lastHeartbeat <= 5_000) return; stopped = true; worker.terminate();` then posts the "unresponsive" error `lastHeartbeat` advances only on heartbeats; no `visibilitychange` handling in the file (grep-verified). The error fires while the tab is hidden — users never see it. Not permissions/approval: record stays enabled, hashes match throughout — purely runtime. **Fix (small):** on `visibilitychange` → visible, reset `lastHeartbeat = Date.now();` and/or raise the threshold (e.g. 90s) or pause the watchdog while `document.hidden`. Hung workers still get caught. **Related minor bug:** top-bar button often missing on fresh load until a remount (tab switch) — client polls the runtime endpoint with a 30s staleTime. **Workaround:** after reloading the app, don't linger in other tabs (<5s), or reload for a fresh worker. [Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462067101958246] [2026-10-07T18:38:13.698Z] Professor Mari [bot]: Howdy! Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.** **Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab: `Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.` If your report is about any of the **Agents**, please provide **the Agent's version** which you can grab from here: `Agents -> Download Agents -> Installed Agents -> Selected Agent -> Installed Version` Thank you, this will help tremendously. This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case. Cheers! [Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462069849362546] [2026-10-07T18:38:30.099Z] spacyH: ` ` ` Marinara Engine diagnostics Version: 2.5.0 Build: 2.5.0+7e28236962a0 Commit: 7e28236962a0 Server OS: Linux 7.0.14-orbstack-00380-ga7e0a2dc9535 (arm64) Server memory: heap 160.7 / 2240 MiB; RSS 283.3 MiB Background wake lock: not reported Last detected freeze: ~2180s suspension, thawed at 2026-10-07T17:47:08.285Z Previous session: shut down cleanly at 2026-10-07T07:19:58.289Z Sessions ended without shutdown: 2 recorded Client OS: macOS 10.15.7 Browser / app shell: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/27.0.1 Safari/605.1.15 Client runtime: {"build":"2.5.0+7e28236962a0","page":"muxs2gf4-6x61if99","persistence":"local","navigation":"navigate","standalone":false,"view":[810,0,0,0],"events":[]} GPU: Apple GPU Server GPU: no NVIDIA GPU detected Main sidecar: not configured Utility sidecar: not configured Decision sidecar: not configured Sidecar load: not measured Active connection: Deepseek Flash Connection provider: openai LLM model: deepseek-flash Mari last acted on: none recorded this session ` ` ` [Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462138640015451] [2026-10-07T18:40:04.720Z] spacyH: Weird, don't know why the diagnostics say I'm on macOS 10.15.7 Intel - it's actually 27.0.1 Apple Silicon [Discord message: https://discord.com/channels/1417099416812392641/1557462067101958246/1557462535509250089] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:09:52 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Fixed on staging by #7262. Ships to main with the next promotion.

<!-- gh-comment-id:6047176249 --> @SpicyMarinara commented on GitHub (Oct 7, 2026): Fixed on `staging` by #7262. Ships to `main` with the next promotion.
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#4052
No description provided.