wavetermdev/waveterm · error
error creating tab: %w
Error message
error creating tab: %w
What it means
CreateTab is the RPC service wrapper around wcore.CreateTab, which inserts a new Tab object into the workspace and persists it. When the core creation fails for any reason (bad workspace id, DB error, missing workspace), the error is wrapped with "error creating tab: %w" and returned to the RPC caller. The %w wrapping preserves the underlying cause for errors.Is/As inspection.
Source
Thrown at pkg/service/workspaceservice/workspaceservice.go:155
}
func (svc *WorkspaceService) GetIcons_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ReturnDesc: "icons",
}
}
func (svc *WorkspaceService) GetIcons() []string {
return wcore.WorkspaceIcons[:]
}
func (svc *WorkspaceService) CreateTab(workspaceId string, tabName string, activateTab bool) (string, waveobj.UpdatesRtnType, error) {
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancelFn()
ctx = waveobj.ContextWithUpdates(ctx)
tabId, err := wcore.CreateTab(ctx, workspaceId, tabName, activateTab, false)
if err != nil {
return "", nil, fmt.Errorf("error creating tab: %w", err)
}
updates := waveobj.ContextGetUpdatesRtn(ctx)
go func() {
defer func() {
panichandler.PanicHandler("WorkspaceService:CreateTab:SendUpdateEvents", recover())
}()
wps.Broker.SendUpdateEvents(updates)
}()
return tabId, updates, nil
}
func (svc *WorkspaceService) SetActiveTab_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"workspaceId", "tabId"},
}
}
func (svc *WorkspaceService) SetActiveTab(workspaceId string, tabId string) (waveobj.UpdatesRtnType, error) {View on GitHub (pinned to a4447c1563)
Solutions
- Check that the workspaceId passed exists (wstore.DBGet[*waveobj.Workspace]) before calling CreateTab
- Unwrap the error with errors.Unwrap / %w chain to see the root cause from wcore.CreateTab
- Verify the wave DB file is writable and not corrupted
- Check for context timeout (DefaultTimeout) issues on slow storage
Example fix
// before
tabId, err := svc.CreateTab("ws-does-not-exist", "New Tab", true)
// after
ws, err := wstore.DBGet[*waveobj.Workspace](ctx, "ws-does-not-exist")
if err != nil { return fmt.Errorf("workspace not found: %w", err) }
tabId, err := svc.CreateTab(ws.OID, "New Tab", true) Defensive patterns
Strategy: validation
Validate before calling
if _, err := wstore.DBGet[*waveobj.Workspace](ctx, workspaceId); err != nil {
return fmt.Errorf("cannot create tab: workspace %s not found: %w", workspaceId, err)
}
tabId, err := svc.CreateTab(workspaceId, tabName, activateTab) Try / catch
tabId, err := svc.CreateTab(workspaceId, tabName, activateTab)
if err != nil {
var notFound *waveobj.ErrNotFound
if errors.As(err, ¬Found) { /* refresh workspace list */ }
return fmt.Errorf("create tab failed: %w", err)
} Prevention
- Validate workspaceId existence before creating tabs
- Keep the client's workspace state in sync after delete operations
- Log the unwrapped cause chain for diagnosis
When it happens
Trigger: Calling CreateTab(workspaceId, tabName, activateTab) with a workspaceId that does not exist in the DB, or when the underlying wcore.CreateTab fails due to storage/transaction errors or context timeout (DefaultTimeout exceeded).
Common situations: Stale workspace references after a workspace was deleted in another client, corrupted wave DB, or slow disk causing the context timeout.
Related errors
- error setting active tab: %w
- error getting tab: %w
- error closing tab: %w
- nil wshrpc passed to wshclient
- no default route
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/5bc3a8deba8ee763.
Report an issue: GitHub.