Mintplex-Labs/anything-llm · error

Failed to fetch workspaces

Error message

Failed to fetch workspaces

What it means

HTTP 500 from GET /api/browser-extension/check, the AnythingLLM browser-extension connectivity probe. It is reached only after validBrowserExtensionApiKey middleware passes, so authentication already succeeded; the failure is inside the handler - resolving the session user (userFromSession) or listing workspaces (Workspace.where / whereWithUser in multi-user mode). The body {connected:false, error:'Failed to fetch workspaces'} deliberately hides the underlying exception.

Source

Thrown at server/endpoints/browserExtension.js:38

    "/browser-extension/check",
    [validBrowserExtensionApiKey],
    async (request, response) => {
      try {
        const user = await userFromSession(request, response);
        const workspaces = multiUserMode(response)
          ? await Workspace.whereWithUser(user)
          : await Workspace.where();

        const apiKeyId = response.locals.apiKey.id;
        response.status(200).json({
          connected: true,
          workspaces,
          apiKeyId,
        });
      } catch (error) {
        console.error(error);
        response
          .status(500)
          .json({ connected: false, error: "Failed to fetch workspaces" });
      }
    }
  );

  app.delete(
    "/browser-extension/disconnect",
    [validBrowserExtensionApiKey],
    async (_request, response) => {
      try {
        const apiKeyId = response.locals.apiKey.id;
        const { success, error } =
          await BrowserExtensionApiKey.delete(apiKeyId);
        if (!success) throw new Error(error);
        response.status(200).json({ success: true });
      } catch (error) {
        console.error(error);
        response

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Check the server console - console.error(error) logs the real exception
  2. Verify the database: container/storage mounted, migrations run, disk not full
  3. If multi-user mode toggled recently, re-authenticate in the browser so userFromSession resolves
  4. As a last resort, disconnect the extension and re-connect to mint a fresh API key
Defensive patterns

Strategy: retry

Type guard

function isConnectedPayload(d) { return d?.connected === true && Array.isArray(d.workspaces); }

Try / catch

try {
  const d = await checkConnection();
  if (!isConnectedPayload(d)) throw new Error(d?.error ?? 'check failed');
} catch (e) {
  await wait(2000);
  const retry = await checkConnection(); // DB blips resolve; persistent failure = server-side
  if (!isConnectedPayload(retry)) reportServerError(retry?.error);
}

Prevention

When it happens

Trigger: Extension calls check with a valid key while the database is down/unreachable; multi-user mode enabled but the session user cannot be resolved (expired/cleared session cookie); the workspaces table is locked or corrupted; Prisma connection pool exhausted.

Common situations: Server restarted with a missing/unmounted database volume; SQLite database file deleted or locked by another process; mode switch between single- and multi-user invalidating session data; extension holds an old key pointing at a re-provisioned instance.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/3c69ded6e5365b31. Report an issue: GitHub.