wavetermdev/waveterm · error
error getting window: %w
Error message
error getting window: %w
What it means
WindowService.GetWindow fetches a Window object from the wstore object database by OID, wrapped in this error when DBGet fails — typically because no window with that OID exists, or a DB/timeout error occurred. The original wstore error is preserved via %w for errors.Is/As inspection.
Source
Thrown at pkg/service/windowservice/windowservice.go:34
"github.com/wavetermdev/waveterm/pkg/wstore"
)
const DefaultTimeout = 2 * time.Second
type WindowService struct{}
func (svc *WindowService) GetWindow_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"windowId"},
}
}
func (svc *WindowService) GetWindow(windowId string) (*waveobj.Window, error) {
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
}
View on GitHub (pinned to a4447c1563)
Solutions
- Verify windowId is a real, currently-open window OID (e.g. from GetWindows/GetWindowList) before calling
- Handle the not-found case: treat it as the window being gone and refresh the window list instead of retrying with the same id
- Unwrap the %w error to distinguish wstore not-found from timeout/DB errors and handle each appropriately
- If stale ids are common, subscribe to wps events for window deletion to invalidate cached ids
Defensive patterns
Strategy: try-catch
Validate before calling
const known = await WindowService.GetWindows();
if (!known.some(w => w.OID === windowId)) throw new Error(`window ${windowId} does not exist`); Type guard
function isKnownWindow(w: waveobj.Window | undefined, id: string): w is waveobj.Window { return w != null && w.OID === id; } Try / catch
window, err := WindowService.GetWindow(windowId)
if err != nil {
var nf *wstore.NotFoundError
if errors.As(err, &nf) { return refreshWindowList() }
return fmt.Errorf("get window %s: %w", windowId, err)
} Prevention
- Subscribe to window deletion wps events to invalidate cached window ids
- Always obtain window ids from live queries, never persisted snapshots
- Check the window still exists after user interaction before further calls on it
When it happens
Trigger: Calling GetWindow with a windowId that does not exist in the DB (deleted window, wrong OID, empty string), or with a valid-shaped OID whose object is not of type window; also a DB timeout (DefaultTimeout) or underlying wstore failure.
Common situations: Frontend holding a stale window id after the window was closed; a race where the window is closed between listing and fetching; copy/pasted or guessed OIDs in scripts/tests; backend DB corruption or migration issues.
Related errors
- error getting block: %w
- error getting workspace: %w
- error creating window: %w
- error getting tab: %w
- error getting window: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/58360e65765da423.
Report an issue: GitHub.