wavetermdev/waveterm · error

error getting client: %v

Error message

error getting client: %v

What it means

clearTempFiles loads the singleton Client record from the wave store to find the temp file zone OID. If the DB read fails (corrupt DB, IO error, store not ready), the error is wrapped as "error getting client: %v" during server temp-file cleanup.

Source

Thrown at cmd/server/main-server.go:430

	// Remove WAVETERM env vars that leak from prod => dev
	os.Unsetenv("WAVETERM_CLIENTID")
	os.Unsetenv("WAVETERM_WORKSPACEID")
	os.Unsetenv("WAVETERM_TABID")
	os.Unsetenv("WAVETERM_BLOCKID")
	os.Unsetenv("WAVETERM_CONN")
	os.Unsetenv("WAVETERM_JWT")
	os.Unsetenv("WAVETERM_VERSION")

	return nil
}

func clearTempFiles() error {
	ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
	defer cancelFn()
	client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
	if err != nil {
		return fmt.Errorf("error getting client: %v", err)
	}
	filestore.WFS.DeleteZone(ctx, client.TempOID)
	return nil
}

func maybeStartPprofServer() {
	settings := wconfig.GetWatcher().GetFullConfig().Settings
	if settings.DebugPprofMemProfileRate != nil {
		runtime.MemProfileRate = *settings.DebugPprofMemProfileRate
		log.Printf("set runtime.MemProfileRate to %d\n", runtime.MemProfileRate)
	}
	if settings.DebugPprofPort == nil {
		return
	}
	pprofPort := *settings.DebugPprofPort
	if pprofPort < 1 || pprofPort > 65535 {
		log.Printf("[error] debug:pprofport must be between 1 and 65535, got %d\n", pprofPort)
		return

View on GitHub (pinned to a4447c1563)

Solutions

  1. Inspect the wrapped inner error for the DB-level cause (permissions, corruption, lock).
  2. Check/repair the wave config DB (wavebase data dir); restore from backup if corrupt.
  3. Verify disk space and file permissions on the store location.
  4. Make temp-file cleanup non-fatal (log and continue) so startup isn't blocked by cleanup issues.
  5. Ensure the store is initialized before clearTempFiles runs.

Example fix

// before
func clearTempFiles() error {
    client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
    if err != nil {
        return fmt.Errorf("error getting client: %v", err)
    }
    ...
}
// after
func clearTempFiles() error {
    client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
    if err != nil {
        log.Printf("clearTempFiles: skipping, %v", err) // non-fatal cleanup
        return nil
    }
    ...
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the wave store is initialized/open before running cleanup
if err := wstore.EnsureDB(ctx); err != nil { return err }

Try / catch

if err := clearTempFiles(); err != nil {
    log.Printf("temp file cleanup skipped: %v", err) // non-fatal
}

Prevention

When it happens

Trigger: Server startup/shutdown path calls clearTempFiles; wstore.DBGetSingleton[*waveobj.Client] returns an error (db open failure, IO error, corrupt record). Note it fails on error, not on a missing singleton.

Common situations: Disk I/O problems on the wave config DB; corrupted local store after a crash; running cleanup in tests without an initialized store.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/1728839b6f984212. Report an issue: GitHub.