Skip to content

Sidebar IPC storm: useTaskPrStatus fires N simultaneous calls on mount, saturating main thread at boot #2251

@andrewm4894

Description

@andrewm4894

Summary

useTaskPrStatus fires one tRPC workspace.getTaskPrStatus call per task on mount. With a moderately full sidebar (e.g. 100 tasks — easy to reach via cloud sync), the burst saturates the Electron main thread for several seconds at boot.

Symptoms

  • App spins at "Checking access..." or appears frozen for 5–15s at launch
  • Main process CPU pegged at ~100%
  • Main log shows the rate-limit warning capping out at 100 calls in 2s:
[warn] [ipc-rate] query workspace.getTaskPrStatus called 100 times in 2000ms
  • Process sample shows the main thread stuck in V8 JIT code reached from a libuv fs callback — JS event loop saturated processing the burst.

Why it scales badly

Reproduced on a dev profile with 100 workspaces, all mode=cloud, none archived, all created within the last 21h. Every cloud task synced from the backend becomes a workspaces row. There is no archival of stale cloud workspaces, so the row count grows linearly with cloud usage.

For cloud tasks without a cloudPrUrl, getTaskPrStatus returns immediately — but the client still pays for 100 simultaneous tRPC IPC roundtrips. For cloud tasks with a cloudPrUrl, the main process additionally hits the GitHub API per task, multiplying the cost.

Repro

  1. Use Code with enough cloud tasks that you accumulate ~100+ workspace rows (or insert dummies)
  2. Restart the app
  3. Watch ~/.posthog-code/logs-dev/main.log for the ipc-rate warnings
  4. App is unresponsive at boot for ~5–15s

Pointers

  • Hook: apps/code/src/renderer/features/sidebar/hooks/useTaskPrStatus.ts:21
  • Main impl: apps/code/src/main/services/git/service.ts:1790
  • Router: apps/code/src/main/trpc/routers/workspace.ts:210

Possible directions (for the team to decide)

  1. Batch — expose getTaskPrStatuses(taskIds[]) and have the sidebar issue one query instead of N.
  2. Skip on client — bail out of the hook for cloud tasks without cloudPrUrl (the common case).
  3. Archive stale cloud workspaces on sync, so the sidebar list stays bounded.
  4. Some combination of the above.

Notes

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingCloudThis issue is related to the cloud

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions