wavetermdev/waveterm · error
error getting client: %w
Error message
error getting client: %w
What it means
After inserting the window, CreateWindow reads the singleton Client record via GetClientData to append the new windowId; this error wraps a failure reading that client record. The window row already exists at this point, so a failure here leaves a partially-created window.
Source
Thrown at pkg/wcore/window.go:120
}
}
window := &waveobj.Window{
OID: windowId,
WorkspaceId: ws.OID,
IsNew: true,
Pos: waveobj.Point{
X: 0,
Y: 0,
},
WinSize: *winSize,
}
err := wstore.DBInsert(ctx, window)
if err != nil {
return nil, fmt.Errorf("error inserting window: %w", err)
}
client, err := GetClientData(ctx)
if err != nil {
return nil, fmt.Errorf("error getting client: %w", err)
}
client.WindowIds = append(client.WindowIds, windowId)
err = wstore.DBUpdate(ctx, client)
if err != nil {
return nil, fmt.Errorf("error updating client: %w", err)
}
return GetWindow(ctx, windowId)
}
// CloseWindow closes a window and deletes its workspace if it is empty and not named.
// If fromElectron is true, it does not send an event to Electron.
func CloseWindow(ctx context.Context, windowId string, fromElectron bool) error {
log.Printf("CloseWindow %s\n", windowId)
window, err := GetWindow(ctx, windowId)
if err == nil {
log.Printf("got window %s\n", windowId)
deleted, _, err := DeleteWorkspace(ctx, window.WorkspaceId, false)
if err != nil {View on GitHub (pinned to a4447c1563)
Solutions
- Ensure wcore.EnsureInitialData has run before creating windows
- Check the wrapped %w error — 'not found' means the client singleton is missing
- Re-initialize the client data or restore the DB
- Clean up the already-inserted window row if aborting
Example fix
// before
client, err := GetClientData(ctx)
if err != nil {
return nil, fmt.Errorf("error getting client: %w", err)
}
// after
client, err := GetClientData(ctx)
if err != nil {
_ = wstore.DBDelete(ctx, waveobj.OType_Window, windowId) // roll back partial creation
return nil, fmt.Errorf("error getting client (is client data initialized?): %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
if _, err := wcore.GetClientData(ctx); err != nil {
if err := wcore.EnsureInitialData(); err != nil {
return fmt.Errorf("client data unavailable: %w", err)
}
} Try / catch
win, err := wcore.CreateWindow(ctx, winSize, workspaceId)
if err != nil && strings.Contains(err.Error(), "error getting client") {
// window row may exist but be unregistered; run CheckAndFixWindow or re-init
if initErr := wcore.EnsureInitialData(); initErr != nil {
return initErr
}
return err
} Prevention
- Always call EnsureInitialData at startup before window operations
- Never delete or hand-edit the client singleton row
- Guard against multiple initialization paths racing at launch
When it happens
Trigger: wcore.CreateWindow when GetClientData(ctx) fails — the client singleton is missing from the DB (fresh/uninitialized DB where EnsureInitialData never ran) or the singleton read errors.
Common situations: Calling CreateWindow before EnsureInitialData on a brand-new install; DB reset/corruption removing the client singleton; read error on the state DB.
Related errors
- error creating workspace: %w
- error inserting window: %w
- error updating client: %w
- stream broker route id not available for file copy
- static files not available before app initialization; use Ap
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/d0fb9ba028836aed.
Report an issue: GitHub.