Tencent/WeKnora · error

recheck owning session

Error message

recheck owning session: %w

What it means

After creating a remote sandbox, the lifecycle re-checks that the owning session still exists via sessionChecker.SessionExists. If that check itself errors, the fresh sandbox is cleaned up and 'recheck owning session: %w' is returned — the library will not keep a newly created sandbox when it cannot confirm the session is still alive. This prevents leaking sandboxes for sessions deleted during creation.

Solutions

  1. Inspect the wrapped error (and any joined cleanup error) for session-store backend detail
  2. Verify session-store availability and read permissions
  3. Retry the whole resolve operation once the session store recovers
  4. Confirm the sessionChecker is configured for the correct store/environment

Example fix

// before
checker := NewStoreSessionChecker(kvClient, "wrong-namespace")
// after
checker := NewStoreSessionChecker(kvClient, sessionsNamespace) // matches where sessions are written
Defensive patterns

Strategy: retry

Validate before calling

// confirm the session exists and the session store is readable before resolving
if ok, err := sessionChecker.SessionExists(ctx, key); err != nil || !ok {
    return fmt.Errorf("session %s not resolvable: (exists=%v, err=%v)", key, ok, err)
}

Try / catch

handle, err := session.Resolve(ctx, key)
if err != nil && strings.HasPrefix(err.Error(), "recheck owning session:") {
    // sandbox was cleaned up automatically; safe to retry once store recovers
    err = retryWithBackoff(ctx, 3, func() error { handle, err = session.Resolve(ctx, key); return err })
}

Prevention

When it happens

Trigger: sessionChecker.SessionExists(ctx, key) returns an error right after a successful Create — the session store backend is unavailable, the read times out, or permissions on the session store fail. The error is joined with cleanupCreated's error via errors.Join.

Common situations: Session store (database/KV) outage or migration concurrent with sandbox creation; read timeout under load; revocation of read permissions between session creation and sandbox creation; misconfigured sessionChecker pointing at the wrong backend.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/91fc5515c46f3f03. Report an issue: GitHub.

Appendix: source

Thrown at internal/sandbox/session_lifecycle.go:370

		}
		for metadataKey, value := range l.metadata(key) {
			request.Metadata[metadataKey] = value
		}
	}
	request.EnvVars = cloneMetadata(l.createRequest.EnvVars)

	handle, err := l.client.Create(ctx, request)
	if err != nil {
		return nil, fmt.Errorf("create remote sandbox: %w", err)
	}
	if err := l.validateHandle(handle, ""); err != nil {
		return nil, errors.Join(err, l.cleanupCreated(ctx, handle))
	}

	exists, checkErr := l.sessionChecker.SessionExists(ctx, key)
	if checkErr != nil {
		return nil, errors.Join(
			fmt.Errorf("recheck owning session: %w", checkErr),
			l.cleanupCreated(ctx, handle),
		)
	}
	if !exists {
		return nil, errors.Join(ErrSandboxSessionDeleted, l.cleanupCreated(ctx, handle))
	}

	binding := l.newBinding(
		key,
		handle.ID(),
		request.TemplateID,
		l.now().UTC(),
	)
	created, bindErr := l.bindings.Create(ctx, key, binding)
	if bindErr != nil {
		return nil, errors.Join(
			fmt.Errorf("create sandbox binding: %w", bindErr),
			l.cleanupCreated(ctx, handle),

View on GitHub (pinned to 988cbb0330)