Error codes and solutions
Every QiankunError thrown by qiankun has a stable code property and a solution link at the end of its message.
Identify framework errors
import { loadMicroApp, QiankunError } from 'qiankun';
const microApp = loadMicroApp({ name, entry, container });
void microApp.mountPromise.catch((error: unknown) => {
if (error instanceof QiankunError) {
console.error(error.code, error.message);
} else {
console.error(error);
}
});Framework errors thrown by the loader, sandbox, and shared modules are all instances of the same QiankunError class. Micro-app code, the browser, and single-spa may also throw other error types, which callers still need to handle.
Public contract
import { type QiankunErrorCode } from 'qiankun';
declare class QiankunError extends Error {
readonly code: QiankunErrorCode;
readonly cause?: unknown;
}The public contract covers identifying framework errors with instanceof QiankunError, the read-only code property, the optional underlying cause property, and public subclasses exported for specific cases (such as LoadAppTimeoutError). Only qiankun creates QiankunError instances; the constructor is not public API. The message ends with a solution link pointing to the Chinese page, and each page links to its English counterpart at the top.
Code conventions
Codes use lowercase words separated by hyphens and describe the cause and remedy. The same cause shares a code across packages. Moving files, rewording a message, or adding other errors does not change existing codes. Branch on error.code instead of comparing complete messages.
Code index
Entry and lifecycles
- lifecycle-missing: Missing lifecycle exports
- entry-duplicate: Duplicate entry scripts
- entry-script-failed: Entry script failed to load
- entry-body-missing: Missing entry response body
App instances and timeouts
- app-already-mounted: Micro app already mounted
- app-not-mounted: Micro app not mounted
- app-unloaded: Micro app unloaded
- app-teardown-failed: Micro app teardown failed
- load-timeout: Micro app loading timed out
- load-timeout-invalid: Invalid loading timeout
Containers and sandbox
- container-required: Missing app container
- container-head-missing: Missing container head node
- sandbox-mount-conflict: Sandbox mount state conflict
- compartment-disposed: Disposed isolation instance
ESM capabilities and modules
- esm-unsupported: Required ESM sandbox capabilities are unavailable
- esm-capability-check-failed: ESM capability check could not complete
- module-hooks-conflict: Conflicting module hooks
- module-descriptor-invalid: Invalid module descriptor
- module-registration-sealed: Document module registration is closed
- module-unresolved: Unresolved module specifier
- module-specifier-reserved: Reserved module specifier
- module-resolve-invalid: Invalid module resolution result
- module-redirect-cycle: Module redirect cycle
- module-context-missing: Missing module load context
- module-rewrite-invalid: Invalid module rewrite spans
