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;
}The public contract is limited to two things: identifying framework errors with instanceof QiankunError, and the read-only code property. Only qiankun creates QiankunError instances; the constructor is not public API. The message ends with a solution link. Links point to Chinese pages, each with an English counterpart.
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
- 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
- container-required: Missing app container
- container-head-missing: Missing container head node
- module-hooks-conflict: Conflicting module hooks
- compartment-disposed: Disposed isolation instance
- 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
