Problem Description
UI/Backend State Desynchronization leading to fatal memory leak.
On fresh start, the Antigravity profile menu shows “Logged in” status, but the language server fails to retrieve the auth token backend-side. This triggers an aggressive crash-restart loop that rapidly exhausts the 8GB RAM, causing system-wide application memory pressure and hang.
Steps to Reproduce
-
Fresh start: Open VS Code (or reload window)
-
Initial State: Antigravity profile menu shows “Logged in” (UI suggests healthy session)
-
Wait 2-5 seconds: Language server startup completes
-
Failure: Auth token error appears (
failed to set auth token) -
Crash Loop: Server enters infinite restart cycle (see logs below)
-
Attempt Recovery: User logs out manually via profile menu
-
Critical Failure: Attempting to log back in hangs indefinitely
-
System Impact: Continuous spawn/terminate processes consume 8GB RAM, causing macOS “Application Memory” warnings and system hang
Actual Behavior
The language server initializes successfully but immediately dies due to auth token failure, creating a tight restart loop that saturates memory:
Copy
[ERROR] failed to set auth token
[WARN] Cache(userInfo): Singleflight refresh failed: You are not logged into Antigravity.
[INFO] initialized server successfully in 225ms ← misleading success
[INFO] Language server shutting down ← immediate death
[ERROR] LS check error: connect ECONNREFUSED 127.0.0.1:51551
[INFO] Language server has exited; restarting ← loop begins
[ERROR] Language server has exited; restarting ← loop accelerates
Observed Impact on 8GB M1:
-
Memory pressure warning within 30-60 seconds
-
VS Code “The window is not responding” dialogs
-
System-wide lag due to memory exhaustion
-
Requires Force Quit to stop the spawn cascade
Expected Behavior
-
Auth state in UI should match backend token state
-
If token is invalid, extension should:
-
Show “Login Required” state (not false “Logged in”)
-
Prompt for re-authentication gracefully
-
NOT enter infinite restart loop
-
-
Failed auth should not cause memory leak via process thrashing
Key Logs
Memory Exhaustion Loop (repeating every 500ms-2s)
Copy
2026-01-27 17:01:53.120 [error] W0127 17:01:53.120201 3846 client.go:137] failed to set auth token
2026-01-27 17:01:53.122 [error] W0127 17:01:53.120848 3846 log_context.go:106] Cache(userInfo): Singleflight refresh failed: You are not logged into Antigravity.
2026-01-27 17:01:53.122 [info] I0127 17:01:53.122354 3846 server.go:1504] initialized server successfully in 225.150458ms
2026-01-27 17:01:53.122 [info] I0127 17:01:53.122530 3846 server.go:1590] Language server shutting down
2026-01-27 17:01:53.125 [error] (Antigravity) LS check error: [unavailable] connect ECONNREFUSED 127.0.0.1:51551
2026-01-27 17:01:53.856 [error] (Antigravity) Language server has exited; restarting
2026-01-27 17:01:53.857 [info] Terminating language server process
2026-01-27 17:01:53.902 [info] Starting language server process with pid 3849 ← new PID, new memory allocation
...[loop repeats, each iteration allocates new process memory until 8GB exhausted]...
Diagnosis
Root Cause: OAuth token is present in UI cache (shows “Logged in”) but invalid/expired in language server keychain/secure storage. The LSP client fails to negotiate the token, triggers shutdown, but the extension host aggressively restarts it without backoff or auth state reset.
M1 8GB Specific: Unified Memory architecture means process thrashing rapidly exhausts system memory (no swap relief), causing immediate user-facing hangs.
Workarounds Tried
-
[ ] Hard Quit VS Code (Cmd+Q): Required to stop memory leak; restart returns to same broken state
-
[ ] Log Out/Log In: Login hangs indefinitely; cannot recover session
-
[ ] Delete Extension Data:
~/Library/Application Support/Antigravity(□□□ test this - may be only fix) -
Phase 1: Basic Process Reset
Issue: Language server stuck in restart loop (logs showed
Language server shutting downimmediately after start).Attempted:
bash
Copy
# Force quit application osascript -e 'quit app "Antigravity"' || true pkill -f "/Applications/Antigravity.app" # Remove runtime folders mv ~/.antigravity/antigravity ~/.antigravity/antigravity.BAK.$(date +%s) mv ~/Library/Application\ Support/Antigravity ~/Library/Application\ Support/Antigravity.BAK.$(date +%s) # Clear quarantine attributes xattr -dr com.apple.quarantine ~/.antigravity xattr -dr com.apple.quarantine /Applications/Antigravity.app # Relaunch open -a "Antigravity"Result: Failed. Logs continued to show
Singleflight refresh failed: You are not logged into Antigravity→ server shuts down → restarts infinitely.
Phase 2: Port Liberation
Theory: Port
58375(and later51551) was stuck/occupied, causingECONNREFUSED.Attempted:
bash
Copy
# Check port occupancy lsof -nP -iTCP:58375 -sTCP:LISTEN || true # Kill processes on Antigravity port ranges sudo lsof -ti:58353,58363,58375,58400-58500 | xargs kill -9 2>/dev/null || true # (Later also tried port 51550, 51551, 51600 when logs showed new ports)Result: Ports were actually free (
lsofreturned empty), but the client still couldn’t connect because the server process shut itself down immediately due to auth failure.
Phase 3: Deep Extension Clean (VS Code/Cursor)
Realization: Antigravity is a Cursor extension, not a standalone app.
Attempted:
bash
Copy
# Kill Cursor entirely pkill -9 -f "Cursor" pkill -9 -f "Cursor Helper" # Remove extension files rm -rf ~/.cursor/extensions/*antigravity* rm -rf ~/.cursor/extensions/*anysphere* # Clear global storage & state rm -rf ~/Library/Application\ Support/Cursor/User/globalStorage/*antigravity* rm -rf ~/Library/Application\ Support/Cursor/User/workspaceStorage/*antigravity* rm -f ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb rm -f ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb.backup # Clear keychain auth security delete-generic-password -s "antigravity" 2>/dev/null || true security delete-generic-password -l "Antigravity" 2>/dev/null || true # Remove extension cache rm -rf ~/Library/Caches/Cursor/CachedExtensions/ # Reinstall from marketplace # (Manual step suggested: reinstall extension → complete auth flow in browser)Result: Still crashing. The error
failed to set auth tokenpersisted, indicating the extension couldn’t retrieve or set authentication credentials even after keychain wipe.
Phase 4: Environmental Fixes
Theory: Disk pressure (228GB Docker.raw) or firewall blocking localhost.
Attempted:
bash
Copy
# Free space (Docker.raw deletion was successful, recovered 228GB) rm -rf ~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw # Disable macOS firewall (temporary test) sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate offResult: Space recovered but didn’t resolve the auth crash. Firewall disabled but issue remained
ECONNREFUSED 127.0.0.1:51551caused by immediate process termination, not network blocking.
Phase 5: Nuclear Option
Final attempt to break the cycle:
bash
Copy
# Kill all anysphere/antigravity processes pkill -9 -f "anysphere" pkill -9 -f "antigravity" lsof -ti:51550,51551,51600 | xargs kill -9 2>/dev/null || true # Launch without extensions (bypass) cursor --disable-extensionsUninstall - Reinstall still fail.
Root Cause Identified (Unfixed)
The crash loop is caused by an authentication initialization failure:
Copy
[W0127 ...] failed to set auth token [...] Cache(userInfo): Singleflight refresh failed: You are not logged into Antigravity. [...] Language server shutting down [...] LS check error: [unavailable] connect ECONNREFUSED 127.0.0.1:51551The server starts → detects no auth token → shuts down immediately → client tries to reconnect → repeat.
All workarounds failed
