Skip to content

VS Code FMA: app auto-launches after Self Service update even when not open #42732

Description

@tux234

Fleet versions

  • Discovered: Latest (observed on current FMA catalog with VS Code 1.111.0+)
  • Reproduced: Latest

Web browser and operating system: macOS (Self Service / Fleet Desktop)


💥 Actual behavior

After updating VS Code via Self Service, the app launches automatically — even when the user didn't have it open. The install script's quit_and_track_application function detects VS Code as "running" due to persistent background helper processes (Code Helper, Code Helper (Renderer), Code Helper (GPU), Code Helper (Plugin)), marks APP_WAS_RUNNING=1, and relaunches the app after the file copy.

🛠️ To fix

Add a custom install script for VS Code (like Chrome, Slack, and Zoom already have at ee/maintained-apps/inputs/homebrew/scripts/) that verifies the app has visible windows via System Events before marking it for relaunch. This avoids changing the shared template that works correctly for all other apps.

The custom script should add a window count check after the osascript "is running" check:

osascript -e 'tell application "System Events"
  set appRunning to (bundle identifier of processes) contains "com.microsoft.VSCode"
  if not appRunning then return 0
  return count of windows of (first process whose bundle identifier is "com.microsoft.VSCode")
end tell'

If window count is 0, skip quit and relaunch.

🧑‍💻 Steps to reproduce

These steps:

  • Describe the workflow that led to the error, but have not yet been reproduced in multiple Fleet instances.
  1. Ensure VS Code is installed on a macOS host but closed (no visible windows)
  2. Check Self Service for a VS Code update
  3. Close VS Code if open, then start the update in Self Service
  4. After the update completes, VS Code launches automatically

🕯️ More info (optional)

Root cause: osascript -e "application id \"com.microsoft.VSCode\" is running" returns true when VS Code's Electron helper processes are active without a visible window. This is VS Code-specific — other apps don't have persistent background helpers that register as the parent app "running."

Reported by @headmin, confirmed by @allenhouchins (script output shows VS Code detected as running when it wasn't). osquery apps table on the affected host shows 4 helper sub-apps with recent last_opened_time values under com.microsoft.VSCode.helper bundle ID.

Metadata

Metadata

Assignees

Labels

:help-solutions-consultingTasks for Solutions ConsultantsbugSomething isn't working as documented

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions