Reference
Error and Warning Codes
Every MJX code MotifJS produces; compiler codes, thrown and reported errors, development warnings, their console messages and what they mean.
Every message the framework and the compiler produce carries an MJX code and appears in the console in the form [motifjs] MJX302: Named route 'note' was not found.. The message texts are in English and may change; in your code, branch on the code, not on the message. How errors are thrown, reported and listened to is on the Error Handling page.
| Kind | What happens |
|---|---|
| thrown | Returns to the caller as a MotifError; caught with try/catch or .catch. |
| reported | Written to the console with errorHandler.report (app.useLogging(false) turns it off) and goes to the errorHandler.addListener listeners; the original error is in cause. Works in production too. |
| warning | Written to the console and the DevTools warning list only in development mode (app.useDevelopment(true)). |
| value | The error comes back as a value or is given to a callback; it is neither thrown nor reported. |
Lazy error |
Given to onError as a Lazy loading error. |
| compile error / warning | Produced by @motifx/compiler during compilation; an error stops the build, and a warning is written to the terminal. |
motif-lint |
A finding of the type-aware checking tool. |
The places shown with ‹…› in the message column are filled with the value at run time.
Compiler
MJX001–MJX018 belong to the compiler and motif-lint. Explanations with examples are in the Compile-time warnings section.
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX001 |
compile warning | In a block-bodied function in JSX child position the condition is moved out of the closure; … |
A local variable defined inside a block-bodied getter with parameters is not visible in the branches. |
MJX002 |
compile warning | "‹name›" is a DOM event name; on a component tag it is bound as a DOM listener … |
The camelCase spelling of a DOM event name on a component tag; it does not reach the props. |
MJX004 |
compile warning | "‹method›()" looks an item up by "‹field›" by scanning a reactive list inside a reactive getter … |
A reactive list is scanned inside a reactive getter with find/findIndex/some/every and a predicate of the form x.field === value; if many components do this, every change means n² reads. Take the element from a keyed map, or read it with untracked. See The trap of every row scanning the list. |
MJX005 |
motif-lint |
<‹tag› ‹prop›={… ? … : …}>: the component declares "‹prop›" as "‹type›" … |
The type of a prop given a ternary does not accept a function; declare the prop as Bind<T>. |
MJX008 |
compile error | A function expression cannot be a JSX child; use an arrow function: {() => …}. |
function () { … } in child position. |
MJX009 |
compile error | Event handler "‹name›" must be a function; … |
A string or boolean value on a DOM event. |
MJX010 |
compile error | Lifecycle hook "‹name›" must be a function, a list of functions, or a reference to one; … |
A value that cannot be called on a lifecycle hook. |
MJX011 |
compile error | Directive "‹name›" does not accept this value; … |
A value that cannot be turned into a getter on x-text, x-html, x-value, x-model or x-watch. |
MJX012 |
compile error | Directive "‹name›" does not accept an object literal. / Directive "‹name›" expects a number or no value: x-chunk or x-chunk={200}. |
An object literal on x-wait / x-display; a value that cannot be a number on x-chunk (a string, an object, an arrow function). |
MJX013 |
compile error | Unsupported JSX tag name: ‹type›. / Unsupported JSX child: ‹type›. |
An unsupported JSX form. |
MJX014 |
motif-lint error |
Cannot read ‹configFile›: ‹message› |
motif-lint could not read the tsconfig file. |
MJX015 |
compile warning, motif-lint |
‹class›.‹member› overrides a ComponentBase member and does not call super.‹member›(…); … |
A member that overrides a ComponentBase member ends without reaching super. |
MJX016 |
compile warning | A "switch" getter in JSX child position is not lowered to bindings.switchCase … / A block-bodied getter returning a ternary is not lowered … |
A switch or ternary getter could not be turned into switchCase / ternary; the content is rebuilt on every change. |
MJX017 |
compile warning | A reactive getter writes "‹target›" (‹op›): a getter that writes what it reads retriggers itself … |
A reactive getter (a JSX getter, an attribute getter, a directive, effect, createComputed, bindings.*) writes a reactive value it reads: ++, a compound assignment, or an assignment to a field it reads elsewhere; a getter that writes what it reads triggers itself (MJX203). Writing to a field it does not read, and to a plain class field, does not warn. Move the write into an event handler or a method; if it has to stay, put the read of that value inside untracked so the getter does not subscribe to it (the whole expression for x++ and compound assignment). |
MJX018 |
compile warning | "‹method›()" changes the reactive list "‹list›" in place inside a reactive getter … |
A reactive list is changed in place inside a reactive getter: sort/reverse always, and push/pop/shift/unshift/splice if the getter also reads the list; a getter that reads the list triggers itself. Work on a copy ([...list].sort(...)), or keep the result in a field or a computed. |
Components and the DOM
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX101 |
thrown | dom.createElement('‹tag›'): no document is available (no DOM environment). |
There is no document while an element is being created; the code is running without a DOM environment. |
MJX102 |
thrown | Invalid element selector "‹description›". |
An invalid element selector. |
MJX103 |
reported | dom.createElementNS('‹tag›') failed. |
createElementNS failed. |
MJX104 |
warning | Skipped inserting a component into the DOM because it contains its own parent. |
A component that contains its own parent was not added to the DOM. |
MJX105 |
reported | Applying router link classes failed. |
The route link classes could not be applied. |
MJX106 |
warning | The placeholder parent changed; rebuilding the component. |
The placeholder's parent changed; the component is being rebuilt. |
MJX107 |
reported | Disposing a child component failed. |
A child component could not be disposed. |
MJX108 |
value | Component is disposed; the result of doWork was discarded. |
The result of doWork was dropped because the component was disposed; doWork resolves with this MotifError, and if the given promise was rejected, the rejection is in cause (see doWork). |
MJX109 |
warning | Content block is disposed; its child was removed from the content body. |
While a ContentBlock was being disposed, one of its parts in the body was removed and disposed; one warning per part (see ContentBody and ContentBlock). |
MJX110 |
Lazy error |
Lazy timeout: the component did not load within ‹ms› ms. |
The Lazy load did not finish within timeoutMs; the error is given to onError, and then Fallbackview is shown. |
MJX111 |
Lazy error |
Lazy aborted: loading the component was cancelled. |
The Lazy load was cancelled with signal; it is given to onError and not reported. |
MJX112 |
reported | resolveComponent: the factory chain exceeded ‹depth› levels; a factory may be returning itself. |
The resolveComponent factory chain went over 100 levels; a factory may be returning itself. |
MJX113 |
thrown | The transport slot has no parent; mount the slot before transporting into it. |
The transport slot has no parent; place the slot before moving content into it. |
MJX114 |
reported | Placing the navigation target into its host failed. |
The navigation target could not be placed in its container. |
MJX115 |
reported | Disposing the previous navigation target failed. |
The previous navigation target could not be disposed. |
MJX116 |
value | Timeout: the listener guard did not settle within ‹ms› ms. |
A listener guard did not settle within timeoutMs; the guard is rejected with this MotifError. |
MJX117 |
reported | Detaching a control failed. |
A control could not be detached. |
MJX118 |
reported | The onRemove callback failed while detaching a control. |
The onRemove callback failed while a control was being detached. |
MJX119 |
reported | Moving a fragment's DOM range stopped: its end marker was not found (possible infinite loop). |
While a fragment's DOM range was being moved, its closing marker could not be found. |
MJX120 |
reported | Scanning a fragment's DOM range stopped: its end marker was not found (possible infinite loop). |
While a fragment's DOM range was being scanned, its closing marker could not be found. |
MJX121 |
warning | This code was compiled for compiler contract ‹compiled›, but the @motifx/core runtime implements contract ‹runtime›. Install matching versions of @motifx/compiler and @motifx/core, and rebuild packages that ship compiled JSX. |
The code was compiled with a compiler contract the core does not support. Bring @motifx/compiler and @motifx/core to matching versions, and rebuild packages that carry compiled JSX. |
MJX122 |
reported | The component ‹hook› hook threw. |
A component hook (onConfig, onBuilt, onMounted, initializeComponent, ref …) or a motif.on("x:…") listener threw, or the promise it returned was rejected; the component keeps being built (see Where errors are caught). |
MJX123 |
reported | The '‹event›' event handler threw. |
An event handler (onclick, motif.on) or an application event listener (app.on, onRouterChanged) threw, or the promise it returned was rejected; the other handlers of the same event run. |
MJX124 |
warning | A spread object on a DOM tag cannot set ‹key›; the key was ignored. Write it on the tag, or use x-html, for HTML you trust. |
An object spread onto a plain DOM tag contains innerHTML or srcdoc; it was not written. For HTML you trust, use x-html or a value written directly on the tag. |
MJX125 |
warning | A spread object on a DOM tag cannot set a javascript: URL on '‹key›'; the value was ignored. Write the attribute on the tag if it is intended. |
An object spread onto a plain DOM tag contains a javascript: address for a link attribute; it was not written. Write a link you mean on purpose directly on the tag. |
MJX126 |
reported | Lazy: loading the component failed and no Fallbackview is set; the host was cleared. |
The Lazy load failed and there is no Fallbackview; the container was emptied. The original error is in cause. |
MJX127 |
thrown | The loaded module has no default export. … / The loaded value is not a component (got ‹got›). … |
A lazy route or Lazy loaded a module without a default export, or a value that is not a component. In the router it becomes the cause of the MJX304 report, and in Lazy it counts as a loading error. |
MJX128 |
warning | ‹cls› overrides ‹member› without calling super.‹member› … / ‹cls› defines '‹member›' as an instance field … / ‹cls› replaces '‹member›' … |
A class component hides a ComponentBase member: an override that does not call super, an instance field that hides a method, or a value put in place of a member the framework sets up. Reported once per class (see Names of class members). |
MJX129 |
reported | The ‹callback› callback given to using threw. |
The onfulfilled or onrejected handler given to using threw, or the promise it returned was rejected. The original error is in cause (see using). |
MJX130 |
reported | Building a chunked child failed. |
A child chunked with x-chunk threw while being built when its turn came; the other children in the chunk keep being built. The .map row that failed is tried again on the list's next update. The original error is in cause (see Large lists). |
Reactivity, bindings and lists
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX201 |
thrown | ListBinding: renderFn must return a component instance, a component class, or a factory function. |
The list binding's renderFn did not return a component, a component class or a factory. |
MJX202 |
warning | ListBinding: duplicate key "‹key›" at index ‹index›. Rows are matched by the item object, not by key, so rendering is not affected; keep keys unique so they identify items. |
A duplicate key was seen while the list was updating. Rows are matched by the item object, so rendering is not affected; keep the keys unique. |
MJX203 |
warning | An effect ran ‹max› times in one flush and keeps triggering itself; it is skipped for the rest of this flush. It probably writes a value it reads (for example state.n++). Wrap the write in untracked(...). |
An effect kept triggering itself in a flush and was skipped for the rest of that flush; it may be writing a value it reads. Put the write inside untracked(...). |
MJX204 |
warning | A component reached a text binding and was not written to the DOM. For a template prop that can change later, write a getter: {() => props.tpl}. Templates that are ready at setup also work as {props.tpl}. |
A component ended up in a text binding and was not written to the DOM. |
MJX205 |
reported | Virtualization: the watch callback threw. |
The Virtualization watch callback threw. |
MJX206 |
warning | Virtualization: autoRefresh stopped; dataRequest may be changing the reactive data it reads on every refresh. |
Virtualization autoRefresh was stopped; dataRequest may be changing the reactive data it reads. |
MJX207 |
reported | Virtualization: loading data failed. |
The Virtualization data could not be loaded (the next page request included). |
MJX208 |
reported | An effect threw. |
An effect or a binding function threw; the other effects in the same flush run, and the binding keeps its last healthy state. |
MJX209 |
warning | An effect tracked ‹count› dependencies in one run (limit ‹limit›), owner ‹owner›. It reads many values one by one, probably a reactive list item by item; look items up by key or read the list with untracked(...). useReactiveMonitor({ dependencies }) sets the limit. |
An effect collected more dependencies in a single run than the threshold (1000 by default); once per effect, and at most ten times per session. With DevTools open, the owning component and binding are written. Usually a reactive list is being scanned from start to end in every row: find the element by key, or read the list with untracked. app.useReactiveMonitor({ dependencies: 2000 }) changes the threshold, and 0 turns it off. See The trap of every row scanning the list. |
MJX210 |
warning | "‹method›()" scans a reactive list of ‹count› items from ‹who›: a change to the fields they read reruns all of them and each rereads the list … |
Two or more instances of the same component type (and binding) scan the same reactive list with find/findIndex/findLast/findLastIndex/some/every, and the list has at least as many items as there are instances; it is caught even if the list comes from props, from another file or from a service, and a plain array does not warn because it is not tracked. Instances are counted by component object, and two bindings of the same instance count as one instance; a hundred rows scanning a three-item settings list does not warn; for effects without an owner (createComputed, a plain effect) the threshold is eight effects. Once per list, and at most ten times per session; with DevTools closed the owner is unknown, so the check does not run. Read the element from a keyed Map or a computed index in the store, or take the list with untracked. useReactiveMonitor({ scans: false }) turns it off. |
MJX211 |
warning | Operation ‹id› (‹kind› ‹name›) was resumed after it ended; its writes are still recorded under it. End an operation after its last write, or use startOperation/endOperation for work that spans callbacks. |
A DevTools operation that had ended was resumed with resumeOperation; the writes made meanwhile are still recorded under that operation. Once per operation, in development only. End the operation after its last write; for work that spans callbacks, use startOperation/endOperation. See DevTools for Packages. |
MJX212 |
thrown | Cannot ‹action›: this is a read-only view made with asReadonly(). Change the data through the reactive object the view was made from. |
A view obtained with asReadonly was written to, a field was deleted from it, or an array-changing method (push, splice, sort, …) or a Map/Set change (set, add, delete, clear) was called on it. The operation is not carried out and the data does not change. Make the change through the reactive object the view was taken from. See A read-only view. |
Routing
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX301 |
warning | RouterView outlet '‹outlet›' was not built within ‹ms› ms, so the route chain cannot be mounted. Does the layout component render a <RouterView>? |
The RouterView outlet was not built in time; the route chain could not be placed. |
MJX302 |
thrown | Named route '‹name›' was not found. |
The named route was not found (navigateByName, href, evict). |
MJX303 |
warning | Redirect loop or too many redirects: ‹chain› |
A redirect loop or too many redirects. It is not thrown; the error page receives this MotifError in params.error. |
MJX304 |
reported | Route execution failed. |
The route could not be carried out (the component constructor or import() failed); the error route is shown. |
MJX305 |
reported | The error fallback route failed. |
The error route itself failed. |
MJX306 |
reported | The ‹hook› hook threw. |
A route hook (onLeave, onEnter, onEntering, onUpdate, onShow) or a useGuard guard threw; a guard error cancels the navigation. |
MJX307 |
reported | Disposing a route component failed. |
A route component could not be disposed. |
MJX308 |
reported | The stack navigation transition failed. |
The stack navigation transition failed. |
MJX309 |
thrown | Router is not initialized. Call useRouter() before navigating. |
Navigation was attempted before the router was set up; useRouter() must be called first. |
MJX310 |
warning | Route path cannot be empty; use '/' for the default child. Under parent "‹parentPath›". |
The route path is empty; use / for the default child. |
MJX311 |
warning | Child route path should start with '/': "‹path›" under parent "‹parentPath›". |
The child route path does not start with /. |
MJX312 |
warning | Child route path resolves to the same full path as its parent: "‹full›". |
The child route path ends up at the same full path as its parent. |
MJX313 |
warning | Multiple routes resolve to the same full path: "‹full›". |
Several routes end up at the same full path. |
MJX314 |
warning | Child route alias should start with '/': "‹alias›" under parent "‹parentPath›". |
The child route alias does not start with /. |
MJX315 |
warning | Route alias resolves to the route's own path: "‹alias›". |
The route alias ends up at the route's own path. |
MJX316 |
warning | Multiple routes use the same alias: "‹alias›". |
Several routes use the same alias. |
MJX317 |
reported | Navigation to '‹uri›' failed. |
Navigation failed with an unexpected error; navigate returns { ok: false, reason: "error", error }. |
MJX318 |
thrown | Route '‹path›' was given a component instance that is already disposed; give a class, a factory or a lazy import so a fresh page can be created. |
The route was entered while the ready component instance given to it had been disposed; it arrives in the cause of the MJX304 report. Give a class, a factory or an import(). |
MJX319 |
warning | Route path has ':' outside '{…}': "‹path›". Parameters are written as "{name}"; ':' only gives a default inside braces. |
There is a : outside the curly braces in the route path (/user/:id); a parameter is written in the {name} form. |
MJX320 |
warning | Route path "‹path›" has a parameter pattern that cannot be used: ‹reason›. |
The route path has a parameter pattern that cannot be used: it does not compile, has an unclosed ( or contains /. |
MJX321 |
warning | History mode cannot be used on a file: address; the router uses hash mode. |
The page was opened from a file: address and mode: 'history' was given; the router works with the hash behaviour (see Router). |
Dependency injection and the application
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX401 |
thrown | Service not registered for token: ‹token› |
The service is not registered. |
MJX402 |
thrown | Async factory used with get() for token ‹token›; use getAsync(). |
A service registered with an async factory or a Promise was asked for with get(); use getAsync(). |
MJX403 |
thrown | Invalid service descriptor. |
An invalid service definition. |
MJX404 |
thrown | Cyclic dependency detected: ‹chain› |
A circular dependency. |
MJX405 |
thrown | Only one ApplicationBuilder instance is allowed. |
A second ApplicationBuilder while an application is running; it is allowed if the previous application is being disposed. |
MJX406 |
thrown | Application.run: host not found for selector: ‹selector› |
The target of run() was not found. |
MJX407 |
warning | getService: no ServiceProvider found for token '‹token›'. |
getService could not find a provider. |
MJX408 |
warning | getService failed for token '‹token›': ‹reason› |
The getService resolution failed. |
MJX409 |
thrown | inject(‹token›) was called outside a service construction; call it in a field initializer or constructor of a class the ServiceProvider creates. |
inject() was called outside the setup of a service; call it in a field initializer or the constructor of a class the provider builds. |
MJX410 |
warning | Multiple sources provided for token '‹token›': ‹sources›. Resolution order is useValue > useFactory > useClass. |
Several sources were given in one registration (useValue, useFactory, useClass); the order of precedence is applied. |
MJX411 |
warning | 'deps' must be an array for token '‹token›'; the invalid deps are ignored. |
deps is not an array; it is ignored. |
MJX413 |
thrown | Service '‹token›' is registered with a function that cannot be constructed. Use { useValue: fn } to provide the function itself or { useFactory: fn } to create the service. |
A function that cannot be constructed (an arrow, async, a method) was registered directly; use { useValue: fn } or { useFactory: fn }. |
MJX414 |
warning | FromService failed for token '‹token›': ‹reason› |
FromService could not resolve; it returns null. |
MJX415 |
warning | 'startup' only applies to singleton services; '‹token›' is registered as ‹lifetime› and is created when it is first resolved. |
startup was given to a registration that is not a singleton; it is ignored, and the service is created on its first resolution. |
MJX416 |
thrown | Application.run: the comment or text node given as host has no parent element. |
The comment or text node given to run() is not inside an element; the application cannot find a place to go. |
MJX417 |
thrown | Application.connectDocument: ‹reason›. |
The value given to connectDocument is not a document, the document has no window (it was closed or never shown), or the document cannot be accessed from another origin. |
MJX418 |
thrown | Application.windows: the browser did not open the window; open it from a user gesture and check the popup blocker. |
app.windows.open or create could not open the window: a popup blocker, or no user gesture. |
MJX419 |
thrown | Application.windows: Picture-in-Picture is not available in this browser or the request was refused. |
With kind: "pip" and fallback: "none", the browser has no Picture-in-Picture or the request was denied. |
MJX420 |
thrown | Application.windows: the window is closed. |
add or focus was called on the handle of a closed window. |
MJX421 |
thrown | Application.windows: ‹reason›. |
A value that is not a window was given to app.windows.attach, or the given window belongs to another origin and its document cannot be accessed. |
MJX422 |
thrown | Application.windows: a disposed component cannot be placed in a window. |
An attempt was made to put a disposed component into a window. |
MJX423 |
reported | Application.windows: the onClosing hook threw. |
The window's onClosing hook threw; the closing completes. |
MJX424 |
thrown | Application.layerOf: the target is neither a component nor a node. |
A target that is neither a component nor a DOM node was given to app.layerOf. |
Disposal
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX501 |
warning | Disposable already disposed. |
An object that was already disposed was disposed again. |
MJX502 |
thrown | Cannot register a disposable on itself. |
An attempt was made to register a disposable on itself. |
MJX503 |
thrown | Errors were thrown while disposing a store. |
Several errors occurred while a store was being disposed; all of them are in the errors array of the AggregateError in the cause field. A single error is thrown as it is. |
MJX504 |
warning | A disposable was added to a DisposableStore that is already disposed; the added object will leak. |
Something was added to a DisposableStore that has been disposed; the added object is not disposed. |
MJX505 |
thrown | Cannot dispose a disposable on itself. |
A store tried to delete itself from inside itself. |
MJX507 |
warning | [‹name›] potential listener LEAK: ‹limit› listeners already; most frequent stack (‹count›): |
The number of effects tracking a reactive field reached the useReactiveMonitor threshold; a possible leak (see Leak tracking). |
Common helpers
| Code | Kind | Message | Meaning |
|---|---|---|---|
MJX601 |
thrown | Sequence contains no elements. |
Query.first() was called on an empty array. |
MJX602 |
thrown | Circuit is open. |
Resilience: the circuit is open; action was not called. |
MJX603 |
thrown | Bulkhead queue is full. |
Resilience: the bulkhead queue is full. |
MJX604 |
thrown | Rate limit exceeded. |
Resilience: the rate limit was exceeded. |
MJX605 |
thrown | Operation timed out. |
Resilience: a timeout; the error's name is TimeoutError. |
MJX609 |
reported | OperationRunner: the operation threw. |
The OperationRunner operation threw. |
MJX610 |
reported | Matching the request path failed. |
The request path could not be matched. |
Next step
For filtering, sorting and grouping arrays, go on to Collection Queries.