plandex-ai/plandex · error
error getting recent model streams: %v
Error message
error getting recent model streams: %v
What it means
In ListPlansRunningHandler, a goroutine fetches active or recent model streams for the requested plan IDs via db.GetActiveOrRecentModelStreams / db.GetActiveModelStreams. When the database query fails, the underlying error is wrapped with this message and sent to errCh; the handler collects it and returns HTTP 500.
Source
Thrown at app/server/handlers/plans_crud.go:460
var branches []*db.Branch
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic in ListPlansRunningHandler: %v\n%s", r, debug.Stack())
errCh <- fmt.Errorf("panic in ListPlansRunningHandler: %v\n%s", r, debug.Stack())
runtime.Goexit() // don't allow outer function to continue and double-send to channel
}
}()
var err error
if includeRecent {
streams, err = db.GetActiveOrRecentModelStreams(planIds)
} else {
streams, err = db.GetActiveModelStreams(planIds)
}
if err != nil {
errCh <- fmt.Errorf("error getting recent model streams: %v", err)
return
}
errCh <- nil
}()
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic in ListPlansRunningHandler: %v\n%s", r, debug.Stack())
errCh <- fmt.Errorf("panic in ListPlansRunningHandler: %v\n%s", r, debug.Stack())
runtime.Goexit() // don't allow outer function to continue and double-send to channel
}
}()
var err error
branches, err = db.ListBranchesForPlans(auth.OrgId, planIds)
if err != nil {
errCh <- fmt.Errorf("error getting branches: %v", err)
returnView on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped %v cause and verify the database is reachable (connection string, network, pool limits).
- Run schema migrations and confirm the model streams tables exist.
- Verify planIds is populated and correctly formed before querying.
- Check Postgres logs at the time of failure for the exact SQL error.
Example fix
// before
streams, err = db.GetActiveOrRecentModelStreams(planIds)
// after
if len(planIds) == 0 { planIds = []string{""} }
streams, err = db.GetActiveOrRecentModelStreams(planIds)
if err != nil {
log.Printf("stream query failed: %v", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go
if len(planIds) == 0 {
return nil // nothing to query; skip DB round-trip
}
if err := db.PingContext(ctx); err != nil {
return fmt.Errorf("db unavailable: %w", err)
} Type guard
func planIdsValid(ids []string) bool { return len(ids) > 0 } Try / catch
streams, err := db.GetActiveOrRecentModelStreams(planIds)
if err != nil {
log.Printf("model streams query failed: %v", err)
http.Error(w, "failed to load model streams", http.StatusBadGateway)
return
} Prevention
- Apply migrations before deploying server updates.
- Monitor DB pool saturation and connection errors.
- Keep planIds non-empty before querying.
- Alert on Postgres error logs for the model_streams tables.
When it happens
Trigger: The Postgres query for model streams fails: DB unreachable, connection pool exhausted, SQL error, table/schema drift (e.g. model_streams table missing or migration not applied), or empty/invalid planIds causing a malformed IN clause.
Common situations: Database outage or restart during deployment; connection-pool saturation under load; running the server against a schema that predates the model streams migration; read-replica failover.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- error adding plan context tokens: %v
- error adding org member: %v
- error listing org roles: %v
- error adding org user: %v
- error getting plan config: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3df09a6d07e63626.
Report an issue: GitHub.