Skip to content

Fastapi server did not survive a sprite restart #81

@khalido

Description

@khalido

I tried out sprites.dev - very cool. To test sprite I made a small fastapi short story at https://wild-red-phoenix-jgh.sprites.app/ and shared the link. This worked great!

Next morning - the link was serving up "Bad Gateway"! 🙁 Not ideal obviously.

Claude Code says:

Service manager PID mismatch after VM boot causes bad gateway

After a VM restart, the Sprite service manager reports a stale PID for a running service, causing the HTTP proxy to return 502 Bad Gateway even though the underlying process is running and responding locally.

Steps to Reproduce:

  1. Configure a service with http_port (e.g., FastAPI on port 8000)
  2. Confirm service works externally
  3. VM gets stopped/restarted (either manually or due to idle timeout)
  4. Attempt to access the HTTP endpoint externally

Observed:

  • External requests return 502 Bad Gateway
  • curl localhost:8000 returns 200 (app is running)
  • sprite-env services list shows a stale PID (e.g., 285) while actual process is PID 3
  • Workaround: sprite-env services stop <name> && sprite-env services start ` fixes the issue

Suggested Fix: On VM boot, the service manager should either:

  1. Reconcile PIDs with actual running processes before marking services as "running"
  2. Or ensure the proxy health-checks the actual port before routing traffic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions