perf(desktop): reduce task runtime CPU and process leaks - #85349
perf(desktop): reduce task runtime CPU and process leaks#85349richardsolomou wants to merge 14 commits into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
🤖 CI report✅ Trunk lane — non-backend laneThis PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes. |
|
React Doctor found 3 issues in 2 files · 3 warnings. 3 warnings
Reviewed by React Doctor for commit |
HostHog preview —
|
|
Problem
Desktop users can see rising CPU use during long task sessions, and cancelled tasks can leave descendant processes running.
PostHog/code#3807 was closed after PostHog Code moved into the monorepo.
Changes
Before:
flowchart LR Event[Stream event] --> Handle[Handle event] Handle --> Store[Write session] Store --> Render[Rebuild and render conversation] classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff; classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000; classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000; class Event phYellow; class Handle phBlue; class Store,Render phGray;After:
flowchart LR Stream[Stream event] --> Batch[50 ms batch] Batch --> Store[Write session once] Store --> Rows[Update changed rows] Immediate[Final or state event] --> Handle[Handle immediately] Handle --> Store classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff; classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000; classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000; class Stream,Immediate phYellow; class Batch,Handle phBlue; class Store,Rows phGray;better-sqlite3native build failed under Node 24.How did you test this code?
pnpm --filter @posthog/core testpnpm --filter @posthog/ui testpnpm --filter @posthog/workspace-server testpnpm typecheckpnpm build:depshogli ci:preflight --strictnode scripts/check-host-boundaries.mjs👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
N/A. This changes internal desktop runtime behavior and does not change a documented workflow.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Codex in Conductor ported PostHog/code#3807 after Richard requested the monorepo migration. No shareable session link is available.
Skills:
posthog-desktop,writing-tests,rs-ship,rs-update-pr,writing-pr-descriptions, andrs-tone.The requested
porting-code-prsskill was unavailable, so the port used the repository layout and current desktop guidance.Conflicts were resolved against the current chat grouping, session diagnostics, and callback interfaces. The source was public, and no private session material was used.