Skip to content

fix: add killWithTimeout to waitForCloudInit SSH processes across all clouds#2425

Merged
la14-1 merged 1 commit intomainfrom
fix/ssh-cloudInit-timeout
Mar 10, 2026
Merged

fix: add killWithTimeout to waitForCloudInit SSH processes across all clouds#2425
la14-1 merged 1 commit intomainfrom
fix/ssh-cloudInit-timeout

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Mar 10, 2026

Why: If a user's network drops during cloud-init wait (laptop lid close, WiFi reconnect, VPN toggle), await proc.exited on SSH polling processes blocks forever. The CLI hangs indefinitely, but the server is already running and billing has started. This affects all 4 SSH-based clouds (Hetzner, AWS, GCP, DigitalOcean).

Changes

  • Add 30s killWithTimeout to each polling SSH command in waitForCloudInit for Hetzner, AWS, GCP, and DigitalOcean (fallback mode)
  • Add 330s killWithTimeout to DigitalOcean streaming SSH (tail -f mode)
  • Pattern matches the existing killWithTimeout usage in waitForSsh (shared/ssh.ts)
  • Bump package version (patch)

Test plan

  • bunx @biomejs/biome check src/ — 0 errors
  • bun test — all pass

-- refactor/code-health

Copy link
Copy Markdown
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review

Verdict: APPROVED
Commit: 73c4110

Findings

None.

Tests

  • bash -n: N/A (TypeScript only)
  • bun test: PASS (1484 tests)
  • biome lint: PASS (0 errors)
  • curl|bash: N/A (TypeScript only)
  • macOS compat: N/A (TypeScript only)

Summary

This PR adds timeout protection to SSH processes in waitForCloudInit across AWS, DigitalOcean, GCP, and Hetzner. The changes prevent hung CLI sessions when networks drop during cloud-init polling.

Implementation is safe:

  • Uses existing killWithTimeout helper (SIGTERM → SIGKILL escalation)
  • Proper try/finally blocks ensure clearTimeout is always called
  • No command injection risk (fixed SSH command strings)
  • No resource leaks (timers properly cleaned up)
  • Version bump follows semver (patch increment)

-- security/pr-reviewer

@louisgv louisgv force-pushed the fix/ssh-cloudInit-timeout branch from 73c4110 to 4489b88 Compare March 10, 2026 09:21
… clouds

Without per-process timeouts, if the user's network drops during
cloud-init polling, the CLI hangs forever while billing continues.
Adds 30s kill timers to each polling SSH command (matching the
waitForSsh pattern in shared/ssh.ts) and 330s to DO's streaming SSH.

Agent: code-health
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@la14-1 la14-1 force-pushed the fix/ssh-cloudInit-timeout branch from 4489b88 to c38ae41 Compare March 10, 2026 09:32
@la14-1 la14-1 merged commit 0126319 into main Mar 10, 2026
5 checks passed
@la14-1 la14-1 deleted the fix/ssh-cloudInit-timeout branch March 10, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants