toeverything/AFFiNE · error · Error

Import service is unavailable

Error message

Import service is unavailable

What it means

requireImportService is a dependency guard: it throws when the ImportService could not be obtained from the framework context (e.g. import dialogs rendered outside a workspace scope), preventing null-service crashes later in the import flow.

Source

Thrown at packages/frontend/core/src/desktop/dialogs/import/index.tsx:140

    };
  }
  if (error instanceof Error) {
    return {
      code: error.name || 'import-error',
      message: error.message || 'Unknown error occurred',
      sourcePath,
    };
  }
  return {
    code: 'unknown',
    message: 'Unknown error occurred',
    sourcePath,
  };
}

function requireImportService(importService?: ImportService) {
  if (!importService) {
    throw new Error('Import service is unavailable');
  }
  return importService;
}

type ImportConfig = {
  fileOptions: { acceptType: AcceptType; multiple: boolean };
  nativeOnly?: boolean;
  importFunction: (args: ImportFunctionArgs) => Promise<ImportResult>;
};

const importOptions = [
  {
    key: 'markdown',
    label: 'com.affine.import.markdown-files',
    prefixIcon: (
      <ExportToMarkdownIcon
        color={cssVarV2('icon/primary')}
        width={20}

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Retry after the import service initializes.
  2. Restart the app if the service remains unavailable.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown by requireImportService when an import function is invoked without an ImportService instance, i.e. the desktop/native import bridge was not provided to the dialog.

Common situations: The user picks an import type that needs the native import service while running in a context where it is missing. Use the desktop app or reload the workspace before importing.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/1ded58b0688663f7. Report an issue: GitHub.