earendil-works/pi · error · Error

${state.staleMessage}

Error message

${state.staleMessage}

What it means

Generic staleness error from the loader runtime's assertActive: the extension API surface was used after the extension stopped being active. The exact reason is carried in state.staleMessage, set when the extension failed to load or was superseded; registration and event methods rethrow it.

Solutions

  1. Avoid using captured API objects after loading completes or fails
  2. Register handlers during the loading phase only
  3. Check extension load logs for the underlying failure that marked the API stale
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/core/extensions/loader.ts:187 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/8175828f9f5d8fe0. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/core/extensions/loader.ts:187

		clearExtensionCache();
	}
	extensionCacheCwd = resolvedCwd;
	return { cwd: resolvedCwd, generation: extensionCacheGeneration };
}

/**
 * Create a runtime with throwing stubs for action methods.
 * Runner.bindCore() replaces these with real implementations.
 */
export function createExtensionRuntime(): ExtensionRuntime {
	const notInitialized = () => {
		throw new Error("Extension runtime not initialized. Action methods cannot be called during extension loading.");
	};
	const state: { staleMessage?: string } = {};
	const eventBusUnsubscribers = new Set<() => void>();
	const assertActive = () => {
		if (state.staleMessage) {
			throw new Error(state.staleMessage);
		}
	};

	const runtime: ExtensionRuntime = {
		sendMessage: notInitialized,
		sendUserMessage: notInitialized,
		appendEntry: notInitialized,
		setSessionName: notInitialized,
		getSessionName: notInitialized,
		setLabel: notInitialized,
		getActiveTools: notInitialized,
		getAllTools: notInitialized,
		setActiveTools: notInitialized,
		// registerTool() is valid during extension load; refresh is only needed post-bind.
		refreshTools: () => {},
		getCommands: notInitialized,
		setModel: () => Promise.reject(new Error("Extension runtime not initialized")),
		getThinkingLevel: notInitialized,

View on GitHub (pinned to 4af9d21d3b)