What the kernel checks
Seven checks and the exact error for each.
When checks run
The kernel refuses a broken composition before any plugin code runs. Every failure is a thrown
error in two lines: what is wrong, then how to fix it. The first line starts with the framework id
in brackets. In @moku-labs/web that is [web].
createPlugin: the plugin spec is checked, for exampleeventsmust be a function.createApp: names and dependencies are checked, before anycreateStateoronInit.app.start(): the app must not be started twice.
| Phase | What is checked |
|---|---|
createPlugin | The shape of the spec. |
createApp | Unique names, reserved names, core plugin names, every dependency present and earlier in the list. |
start and stop | start() once per app, stop() only after start(). |
Type errors come first. Most mistakes on this page also fail tsc, so an editor shows them as you
type. The runtime checks catch the rest: a list built at runtime, a cast, plain JavaScript.
The checks
Each message below is captured from the installed kernel when the site is built, by making the mistake for real. It is never typed by hand, so it cannot drift from what your app prints.
-
duplicate-name· checked atcreateApp[web] Duplicate plugin name: "auth". Each plugin must have a unique name.Fix: List each plugin once in createApp({ plugins }).
-
missing-dependency· checked atcreateApp[web] Plugin "billing" depends on "auth", but "auth" is not registered. Add "auth" to your plugin list before "billing".Fix: Add the plugin it depends on to the plugins list.
-
dependency-order· checked atcreateApp[web] Plugin "billing" depends on "auth", but "auth" appears after "billing". Move "auth" before "billing" in your plugin list.Fix: Put a dependency before the plugin that depends on it.
-
reserved-name· checked atcreateApp[web] Plugin name "start" conflicts with a reserved app method. Choose a different plugin name.Fix: Rename the plugin: start, stop, emit and require are app methods.
-
core-plugin-clash· checked atcreateApp[web] Plugin name "log" conflicts with core plugin "log". Choose a different plugin name.Fix: Rename the plugin: log and env are core plugins on every ctx.
-
events-object· checked atcreatePlugin[web] Plugin "analytics" has invalid events: expected a function. Provide a function like: events: register => ({ "event:name": register<PayloadType>() })Fix: Declare events with a function: events: register => ({ ... }).
-
double-start· checked atstart[web] App already started. start() can only be called once.Fix: Call app.start() once per app.
Why errors and not warnings
An agent reads errors. It skims warnings. A startup error with the plugin name in it is the cheapest review step in the lifecycle, so the kernel makes it impossible to skip.