Issue: Auth Token Mismatch Causes Crash Loop & Memory Exhaustion on M1 Mac 27.01.26

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

  1. Fresh start: Open VS Code (or reload window)

  2. Initial State: Antigravity profile menu shows “Logged in” (UI suggests healthy session)

  3. Wait 2-5 seconds: Language server startup completes

  4. Failure: Auth token error appears (failed to set auth token)

  5. Crash Loop: Server enters infinite restart cycle (see logs below)

  6. Attempt Recovery: User logs out manually via profile menu

  7. Critical Failure: Attempting to log back in hangs indefinitely

  8. 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 down immediately 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 later 51551) was stuck/occupied, causing ECONNREFUSED.

    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 (lsof returned 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 token persisted, 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 off
    

    Result: Space recovered but didn’t resolve the auth crash. Firewall disabled but issue remained ECONNREFUSED 127.0.0.1:51551 caused 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-extensions
    

    Uninstall - 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:51551
    

    The server starts → detects no auth token → shuts down immediately → client tries to reconnect → repeat.

    All workarounds failed

[Error - 19:00:45] antigravity client: couldn’t create connection to server.

Error: connect ECONNREFUSED 127.0.0.1:53420

at TCPConnectWrap.afterConnect \[as oncomplete\] (node:net:1637:16)

Bug Report: Antigravity Stuck in “Authenticating” State After Login Attempt


Status: Critical - Application Unusable
Regression: Yes (worked previously or on stable macOS versions)


Environment

  • Device: iMac M1 (iMac21,1)

  • RAM: 8GB Unified Memory

  • macOS: 26.0.1 Beta (Build 25A362)

  • Antigravity Version: Latest (language_server_macos_arm 140MB, Jan 24 2026)


Issue Progression (Timeline)

Phase 1: Initial Symptom - Crash Loop

  • Launch Antigravity → Immediate error: “Antigravity server crashed unexpectedly”

  • Error: connect ECONNREFUSED 127.0.0.1:[RANDOM_PORT]

  • Logs showed: Parent pipe closed on language server process [PID] followed by failed to set auth token

  • Language server binary (language_server_macos_arm) started but exited within milliseconds

Phase 2: Post-Troubleshooting - Clean State Hang

After clearing all caches (~/Library/Application Support/Antigravity, ~/.antigravity, ~/.gemini, ~/Library/Caches/com.anysphere.antigravity), killing competing processes (Chrome, Docker), and freeing memory (49% free):

  • Crash errors stopped appearing

  • Application launched to main UI

  • Right panel showed: “One moment, the agent is currently loading…” indefinitely

Phase 3: Current State - Authentication Deadlock

  • Clicked “Log in with Google” button

  • Successfully authenticated in browser (Google OAuth flow completed)

  • Returned to Antigravity

  • Status bar shows: “Antigravity: Authenticating” (yellow badge) - stuck indefinitely

  • No error messages displayed

  • No timeout after 30+ minutes

  • Cannot retry login (button disabled or unresponsive)

  • Force Quit → Relaunch → Returns to “Authenticating” state (loop persists)


Steps to Reproduce Current State

  1. Start with clean install/cleared caches on macOS 26.0.1 Beta

  2. Launch Antigravity → Wait for main UI (no crash errors)

  3. Click “Log in with Google” in top-right corner

  4. Complete OAuth flow in browser successfully

  5. Return focus to Antigravity window

  6. Observe: Status bar shows “Authenticating” forever

  7. Kill app (Cmd+Q or pkill -9 "Antigravity")

  8. Relaunch Antigravity

  9. Observe: Returns immediately to “Authenticating” state without prompting for login again


Key Diagnostic Findings

Binary Health Check

bash

Copy

$ file /Applications/Antigravity.app/.../language_server_macos_arm
Mach-O 64-bit executable arm64

$ /Applications/Antigravity.app/.../language_server_macos_arm --help
# Starts successfully, shows help output
# Maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined

Result: Binary is valid ARM64, runs perfectly when launched manually from Terminal. Issue only occurs when spawned by the application sandbox.

Auth Cache State

After failed login:

  • ~/.gemini - Empty or non-existent

  • ~/Library/Application Support/Antigravity - Contains no valid session token

  • Keychain: May contain stale/incomplete auth entry (cannot verify due to macOS 26 keychain changes)

Process State During “Authenticating”

bash

Copy

$ ps aux | grep -i antigravity
# Main Antigravity process exists
# NO language_server_macos_arm process running (unlike initial crash loop)
# Or: LSP spawns then immediately dies before auth completes

Network State

  • No firewall blocking (tested with socketfilterfw disabled)

  • DNS resolves correctly

  • Can reach *.google.com and Anysphere endpoints from browser/curl


Hypothesis: Auth State Corruption on macOS 26

The authentication flow appears to complete in the browser but fails to handshake back to the Antigravity app. Possible causes:

  1. URL Scheme Handler Failure: macOS 26 may block the antigravity:// callback URL from the browser to the app due to new security sandboxing

  2. Keychain Access Denied: LSP cannot write auth token to keychain due to macOS 26 privacy restrictions (no prompt shown)

  3. State Machine Deadlock: App transitions to “Authenticating” state but receives no callback, has no timeout mechanism, and persists state across restarts (saved in ~/Library/Saved Application State/)


Workarounds Attempted (All Failed)

Table

Copy

Attempt Result
Clear ~/Library/Saved Application State/com.anysphere.antigravity.savedState Auth state persists
Clear all caches (~/.gemini, ~/.antigravity, ~/Library/Application Support/Antigravity) Returns to “Authenticating” immediately
Revoke app permissions in Google Account and retry Same hang after re-auth
Disable firewall / network security No change
Launch with --no-sandbox flags Auth callback still fails
Force kill LSP before it crashes Main app remains stuck waiting for auth

Critical Observation: Binary Works, Integration Fails

Manual Test:

bash

Copy

$ /Applications/Antigravity.app/.../language_server_macos_arm --standalone
# Server starts, listens on port, responds to health checks

App Integration:

  • App launches binary → Binary exits or ignores auth request → App hangs in “Authenticating”

  • Parent pipe monitoring (server.go:1548) may be interfering with auth token callback

  • macOS 26 may require new Entitlements for Keychain access or URL scheme handling that the current build lacks


Expected vs Actual Behavior

Expected:

  1. Click “Log in with Google”

  2. Browser OAuth flow

  3. Auto-return to Antigravity

  4. Status changes to “Ready” or shows user profile

  5. AI features enabled

Actual:

  1. Click “Log in with Google”

  2. Browser OAuth flow (completes successfully)

  3. Return to Antigravity

  4. Status stuck at “Antigravity: Authenticating” (yellow badge)

  5. No timeout, no error, no retry option

  6. Force Quit → Relaunch returns to same state

  7. Deadlock persists indefinitely


Request for Developers

  1. Add timeout mechanism: “Authenticating” should timeout after 30s and show error/retry button

  2. Clear auth state button: Force reset authentication without clearing all app data

  3. Debug build: Provide build with verbose logging for server.go auth flow and URL scheme handling

  4. macOS 26 entitlement check: Verify com.apple.security.cs.allow-unsigned-executable-memory and Keychain access entitlements are properly signed

  5. Manual auth token entry: CLI method to inject token bypassing browser flow for testing


Attachments

  • Screenshot 1: “Authenticating” hang state (yellow status badge)

  • Screenshot 2: Crash loop errors (from initial state)

  • Logs: server.go showing Parent pipe closed and failed to set auth token

  • System Report: macOS 26.0.1 (25A362) on iMac21,1