Fixing Antigravity IDE "Reload Window" Crashes When Running Multiple WSL 2 Windows
If you use Antigravity IDE with WSL 2 (Ubuntu) and open two separate IDE windows to work on two projects at the same time (for example, a frontend repo and a backend/ERP repo), you may have run into a frustrating bug:
⚠️ The Symptom: Both WSL windows work fine simultaneously. However, the moment you close the first window you opened, the remaining window immediately loses its connection, becomes corrupted, and forces you to click Reload Window (killing running tasks and agent sessions).
Below, we’ll walk through the root cause inside the antigravity-remote-wsl extension and how to fix it permanently.
Part 1: Why Closing One Antigravity WSL Window Corrupts the Other
Closing one Antigravity IDE window while another is open in WSL breaks the remaining window. Inspecting the WSL server logs (~/.antigravity-ide-server/) and Windows client logs (%APPDATA%\Antigravity IDE\logs\) reveals why.
The Root Cause: Shared Process Group (SIGHUP) + Single Keepalive
All Antigravity IDE windows connected to the same WSL distro share a single Linux backend server (antigravity-ide-server). However, the built-in Remote - WSL extension (antigravity-remote-wsl/dist/extension.js) has two flaws in the bash script it uses to launch that server:
1. The Server Isn't Detached from Window 1's Pseudo-Terminal (pts)
When Window 1 opens a WSL project, it runs wsl.exe --distribution ubuntu -- bash -c '...' and launches the server in the background using &:
$SERVER_SCRIPT --start-server --host=127.0.0.1 ... &> $SERVER_LOGFILE &Because bash -c runs non-interactively without job control, backgrounding with & leaves antigravity-ide-server attached to Window 1's pseudo-terminal (pts) and Session ID (SID):
PID PPID PGID SID TT COMMAND
19277 19274 19277 19277 pts/2 bash (Window 1's wsl.exe keepalive script)
19303 19277 19277 19277 pts/2 sh .../bin/antigravity-ide-server
19313 19303 19277 19277 pts/2 node .../out/server-main.jsWhen Window 2 opens a second WSL project, the script sees antigravity-ide-server is already running, connects Window 2 to that same server, and exits its own setup script immediately.
When you close Window 1, Windows terminates Window 1's wsl.exe process. Linux destroys pts/2 and sends SIGHUP (hangup) to the entire 19277 process group — instantly killing the shared antigravity-ide-server while Window 2 is still open.
Within milliseconds, Window 2 loses its socket connection, spawns a brand-new server on a new port, and tries to pass its old reconnection token to the new server. The new server rejects it in remoteagent.log:
[error] [ManagementConnection] Unknown reconnection token (never seen).
[error] [ExtensionHostConnection] Unknown reconnection token (never seen).Because the old server process was killed, Window 2's state is lost and it forces a Reload Window.
2. Only Window 1 Runs the WSL Idle Keepalive Loop
Windows automatically shuts down a WSL distro after ~8 seconds if zero wsl.exe processes are running. In the original script, only the window that started the server stays in the while ... sleep 300 keepalive loop; subsequent windows hit else print_install_results_and_exit 0 and exit wsl.exe immediately.
Part 2: How to Fix It
Option A: Zero-Config Workarounds
If you don't want to modify extension files:
- Use a Multi-Root Workspace: Instead of opening a second window, use File → Add Folder to Workspace... to open both Ubuntu projects inside a single window.
- Close Window 2 First: If you open two windows, avoid closing the first window you opened while the second window is still active.
Option B: The Permanent Fix (Patching antigravity-remote-wsl)
We can fix extension.js directly by making two small adjustments to the embedded startup script:
- Launch
$SERVER_SCRIPTwithnohup setsid ... </dev/nullso the server runs in its own independent Linux session (SID) with no controlling terminal (TT = ?). Closing Window 1 will no longer sendSIGHUPto the server. - Remove the
if / elsesplit at the end of the startup script so every open WSL window maintains its ownwsl.exekeepalive loop for as long as that window stays open.
Step 1: Run the Patch Script in PowerShell
Close your Antigravity IDE windows, open PowerShell, and run the following script. It automatically creates a backup (extension.js.bak) before applying the patch:
$p = "$env:LOCALAPPDATA\Programs\Antigravity IDE\resources\app\extensions\antigravity-remote-wsl\dist\extension.js"
$bak = "$p.bak"
if (-not (Test-Path -LiteralPath $bak)) {
Copy-Item -LiteralPath $p -Destination $bak -Force
Write-Output "Backup created at: $bak"
}
$content = [System.IO.File]::ReadAllText($p)
$oldLaunch = '$SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --use-host-proxy --disable-websocket-compression --without-browser-env-var --enable-remote-auto-shutdown --accept-server-license-terms &> $SERVER_LOGFILE &'
$newLaunch = 'nohup setsid $SERVER_SCRIPT --start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --use-host-proxy --disable-websocket-compression --without-browser-env-var --enable-remote-auto-shutdown --accept-server-license-terms </dev/null &> $SERVER_LOGFILE &'
$oldKeepalive = @"
# Finish server setup and keep script running\nif [[ -z `$SERVER_RUNNING_PROCESS ]]; then\n\techo "`${e}: start"\n\techo "exitCode==0=="\n\techo "listeningOn==`$LISTENING_ON=="\n\techo "connectionToken==`$SERVER_CONNECTION_TOKEN=="\n\techo "logFile==`$SERVER_LOGFILE=="\n\techo "osReleaseId==`$OS_RELEASE_ID=="\n\techo "arch==`$ARCH=="\n\techo "platform==`$PLATFORM=="\n\techo "tmpDir==`$TMP_DIR=="\n\t`${a.map(e=>``echo "`${e}==`$`${e}=="``).join("\n")}\n\techo "`${e}: end"\n\n\techo "`${e}: Server installation script done"\n\n\tSERVER_PID="`$(cat `$SERVER_PIDFILE)"\n\tSERVER_RUNNING_PROCESS="`$(ps -o pid,args -p `$SERVER_PID | grep `$SERVER_SCRIPT)"\n\n\trelease_lock\n\n\twhile [[ -n `$SERVER_RUNNING_PROCESS ]]; do\n\t\tsleep 300;\n\t\tSERVER_RUNNING_PROCESS="`$(ps -o pid,args -p `$SERVER_PID | grep `$SERVER_SCRIPT)"\n\tdone\nelse\n\tprint_install_results_and_exit 0\nfi
"@
$newKeepalive = @"
# Finish server setup and keep script running\necho "`${e}: start"\necho "exitCode==0=="\necho "listeningOn==`$LISTENING_ON=="\n\techo "connectionToken==`$SERVER_CONNECTION_TOKEN=="\necho "logFile==`$SERVER_LOGFILE=="\necho "osReleaseId==`$OS_RELEASE_ID=="\necho "arch==`$ARCH=="\necho "platform==`$PLATFORM=="\necho "tmpDir==`$TMP_DIR=="\n`${a.map(e=>``echo "`${e}==`$`${e}=="``).join("\n")}\necho "`${e}: end"\n\necho "`${e}: Server installation script done"\n\nif [[ -z `$SERVER_PID && -f `$SERVER_PIDFILE ]]; then\n\tSERVER_PID="`$(cat `$SERVER_PIDFILE)"\nfi\nSERVER_RUNNING_PROCESS="`$(ps -o pid,args -p `$SERVER_PID | grep `$SERVER_SCRIPT)"\n\nrelease_lock\n\nwhile [[ -n `$SERVER_RUNNING_PROCESS ]]; do\n\tsleep 300;\n\tSERVER_RUNNING_PROCESS="`$(ps -o pid,args -p `$SERVER_PID | grep `$SERVER_SCRIPT)"\ndone
"@
if (-not $content.Contains($oldLaunch) -or -not $content.Contains($oldKeepalive)) {
Write-Error "Target strings not found — extension.js may already be patched or on a different version."
} else {
$updated = $content.Replace($oldLaunch, $newLaunch).Replace($oldKeepalive, $newKeepalive)
[System.IO.File]::WriteAllText($p, $updated)
Write-Output "Successfully patched extension.js!"
}Step 2: Restart the Existing WSL Server Process
Stop any old antigravity-ide-server instance that was launched before the patch:
wsl -e bash -lc "pkill -f antigravity-ide-server"Reopen Antigravity IDE and launch as many WSL windows as you need — you can now close them in any order without disconnecting or corrupting your remaining windows.
💡 Note: When Antigravity IDE installs a version update in the future, it may overwrite
extension.js. If the bug hasn't been fixed upstream yet, simply re-run the PowerShell script above.
How to Restore the Original File (Optional)
If you ever want to revert to the unpatched file, run:
$p = "$env:LOCALAPPDATA\Programs\Antigravity IDE\resources\app\extensions\antigravity-remote-wsl\dist\extension.js"
Copy-Item -LiteralPath "$p.bak" -Destination $p -Force