Skip to content

SpawnClient stops busy instances from the browser: lifecycle loop passes isIdle:true on real AWS, so any open portal tab stops every spawn-managed instance past its idle-timeout #126

Closed

Description

@scttfrdmn

Found by the portal functional audit (2026-11-10, spawn-ts 0.8.1 in the spore-host#620 portal build).

SpawnClient.tick() runs spored's lifecycle engine in the browser, against real AWS, and passes isIdle: true for every instance on every tick (dist/core/client.js:110-114, src/core/client.ts:231 on main). evaluate() (core/lifecycle.js:145-157) measures idleness as now - lastActivityMs, and lastActivityMs is the launch time (aws/ec2.js:379, "approximate here"). So once an instance is older than its spawn:idle-timeout, any open portal tab calls StopInstances on it, however busy it is.

This hits every spawn-managed instance in the region, not just ones the tab launched: EC2Provider.list() filters only tag:spawn:managed=true. CLI launches are affected the most. Go spawn launch defaults --idle-timeout 1h when no --ttl is given (cmd/zombie_guard.go:27), and spawn:launch-time is always set (pkg/aws/tags.go:100). So a CLI job launched without --ttl gets stopped one hour after launch, the first time anyone opens the portal's Instances page.

Before spore-host#675 this was latent, because StopInstances was AccessDenied and the rejection went unhandled. #675 grants Stop/Start/Terminate on spawn:managed instances, so the bug can now fire.

Evidence (Playwright run against the real portal code with a stubbed SDK). A fake account held a CLI-style instance cli-job (c7g.large, launched 2 h ago, spawn:idle-timeout=30m, spawn:iam-user=…:user/alice). I opened #/instances and clicked nothing. Within 4 s:

ec2:StopInstances(i-0aaa000000000000a) -> ok
log: "cli-job idle: stop — idle timeout reached (120m)"

Changing Mode in the header re-mounts the surface, and it issued StopInstances again.

The same loop also terminates on TTL and cost-limit (rules 2 and 3), duplicating spored and the reaper. For TTL that's harmless. computeSeconds is read from a tag that spored owns.

Fix:

  • On a real provider (provider.isReal), take no idle action: the browser has no activity signal.
  • Better: take no lifecycle actions from the browser at all, because spored and the reaper own enforcement. Keep warnings and the orphan banner (which already asks for confirmation).
  • If TTL enforcement stays, scope it to instances this client launched, and say so in the event log.
  • Test: with a real-shaped provider, an instance with idleTimeoutMs older than its timeout gets no stop or hibernate call.

Related: spore-host#675 (the grant that makes this live), spawn-ts#125.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corebugcost-safety

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions