wavetermdev/waveterm · error
error creating window: %w
Error message
error creating window: %w
What it means
WindowService.CreateWindow delegates actual window creation to wcore.CreateWindow and wraps any failure with this error. Underlying causes include invalid workspace id, invalid window size, or failures persisting/initializing the new window object in the DB.
Source
Thrown at pkg/service/windowservice/windowservice.go:48
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancelFn()
window, err := wstore.DBGet[*waveobj.Window](ctx, windowId)
if err != nil {
return nil, fmt.Errorf("error getting window: %w", err)
}
return window, nil
}
func (svc *WindowService) CreateWindow_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"ctx", "winSize", "workspaceId"},
}
}
func (svc *WindowService) CreateWindow(ctx context.Context, winSize *waveobj.WinSize, workspaceId string) (*waveobj.Window, error) {
window, err := wcore.CreateWindow(ctx, winSize, workspaceId)
if err != nil {
return nil, fmt.Errorf("error creating window: %w", err)
}
return window, nil
}
func (svc *WindowService) SetWindowPosAndSize_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
Desc: "set window position and size",
ArgNames: []string{"ctx", "windowId", "pos", "size"},
}
}
func (ws *WindowService) SetWindowPosAndSize(ctx context.Context, windowId string, pos *waveobj.Point, size *waveobj.WinSize) (waveobj.UpdatesRtnType, error) {
if pos == nil && size == nil {
return nil, nil
}
ctx = waveobj.ContextWithUpdates(ctx)
win, err := wstore.DBMustGet[*waveobj.Window](ctx, windowId)
if err != nil {View on GitHub (pinned to a4447c1563)
Solutions
- Unwrap the %w error to see the underlying wcore/wstore cause and fix the specific step that failed
- Validate winSize (non-nil, positive width/height) and confirm workspaceId references an existing workspace before calling
- Re-fetch the current workspace list; if the workspace is gone, create/select a valid one first
- Retry once only if the underlying error is transient (e.g. DB timeout); not-found/invalid-input errors will not self-heal
Example fix
// before
WindowService.CreateWindow(ctx, &waveobj.WinSize{Width: 0, Height: 0}, staleWorkspaceId)
// after
ws, _ := WorkspaceService.GetWorkspace(validWorkspaceId)
WindowService.CreateWindow(ctx, &waveobj.WinSize{Width: 1200, Height: 800}, ws.OID) Defensive patterns
Strategy: validation
Validate before calling
function validWinSize(s) { return s != null && Number.isFinite(s.Width) && s.Width > 0 && Number.isFinite(s.Height) && s.Height > 0; }
if (!validWinSize(winSize) || !workspaces.some(ws => ws.OID === workspaceId)) throw new Error("invalid window creation input"); Type guard
function isValidWinSize(s: waveobj.WinSize | null | undefined): s is waveobj.WinSize {
return s != null && s.Width > 0 && s.Height > 0;
} Try / catch
win, err := WindowService.CreateWindow(ctx, winSize, wsId)
if err != nil {
return fmt.Errorf("create window: %w", err) // inspect wrapped wcore cause
} Prevention
- Validate winSize dimensions are positive numbers before calling
- Resolve workspaceId from the current workspace list, not cached state
- Only retry creation if the wrapped error is transient (e.g. timeout)
When it happens
Trigger: CreateWindow called with a workspaceId that does not exist, a nil or out-of-range winSize (zero/negative dimensions), or when wcore's window creation step (object persistence, electron window spawn coordination) fails.
Common situations: Frontend creating a window right after a workspace was deleted; passing a stored-but-stale workspace OID; running in a headless/test environment where window creation backend steps are unavailable; invalid persisted window-size config values.
Related errors
- error creating workspace: %w
- error getting window: %w
- error updating workspace: %w
- error getting workspace: %w
- error deleting workspace: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/ea738c1a336a2cd7.
Report an issue: GitHub.