Errors and troubleshooting
Learn to read diagnostics and distinguish template, state, layout, and lifetime problems.
janelkit Included with janelkit. Nothing extra to install. What you will learn
- Locate the stage where an error occurs before changing code.
- Distinguish state, lifetime, layout and blocking-work problems.
- Recognize confirmed limitations and produce a small reproduction.
Read the location before changing code
A diagnostic tells you where a problem was detected: file, line, and column, followed by a message. It may show the source line, a caret pointing to the position, and a suggestion. Start at that location. A misspelled state name can look like a broken renderer if you skip the original message.
There are different stages of failure. Parsing checks the file structure. Compilation validates template names and produces the view description. Script execution runs your Python setup. Event handling runs Python later, when a user acts. An async task may store an error in its .error property instead of throwing it during setup.
| Stage | Example cause | First check |
|---|---|---|
| File structure | Two script sections or multiple template roots | The .janel component sections |
| Template compile | Unknown tag, event, property, or undefined name | Spelling and the documented element API |
| Qt startup | Generated QML contains a color or assignment Qt rejects | Mount or run the application; build alone does not load QML |
| Python setup | Missing imported module or top-level exception | Traceback pointing into the script |
| Event handling | A function assumes a missing argument | Handler signature and event payload |
| Async work | Service request fails | task.error and application logging |
| Styling | Unsupported CSS declaration | Compiler warnings and supported-property reference |
The value changes, but the view does not
First ask which value the template actually reads. In a Python script, change count.value, not a replacement variable called count. In the template, a direct state name is unwrapped automatically, so use {count}. For a module attribute that is a state, direct-name unwrapping does not apply in the same way: import the state name directly or read the attribute value explicitly.
When a state wraps a list or dictionary, mutate the reactive value you got back, not the original container passed to state. The framework copies supported containers into reactive versions. If you use an unsupported custom mutable object, the framework cannot infer every internal mutation; consider immutable replacement or the documented notify() escape hatch.
# In a component script:
from janelkit import state
count = state(0)
def increment():
count.value += 1
# In its template:
# <text>{count}</text>
# <button on:click={increment}>Increment</button>CopyHow it works
- count refers to the reactive wrapper. Reassigning count = 1 loses that wrapper rather than updating it.
- count.value += 1 tells the wrapper about a new value, allowing dependent bindings to update.
- The callback reference increment is passed to on:click so the action runs when clicked.
What you should see
Each click updates the displayed count. Unrelated template bindings do not need to be updated manually.
Common mistakes
- Python templates use and, or, not, True, False, and None. JavaScript operators such as && and === are not valid Python expressions.
A callback did not run when you expected
A handler can be a function reference, such as on:click={save}, or inline code, such as on:click={save()}. Both are valid but have different expression forms. A bare callable is invoked by the framework; inline code executes when the event occurs. If setup calls save() in the script, however, that is ordinary Python setup and happens immediately.
A computed value is for deriving a result, not performing a side effect. Calling a service or mutating state from a computed function can create confusing evaluation timing. Put user actions in handlers and intentional reactive side effects in effect. If an event carries a value, check the documented payload rather than assuming every event is a mouse object.
An input resets or a resource keeps running
A conditional #if destroys the inactive branch and its component instances. Recreating a branch starts new local state. A #key change deliberately recreates its contents. In contrast, #hidden, list rows out of view and the covered pages of janelkit-router keep Python instances alive while their visible updates wait.
Check who owns the resource. An effect or timer created during component setup is tied to that component lifetime. A timer created in an ordinary module may not have that owner and may require explicit stopping. The before_leave hook guards closing a window with the X and leaving a page of janelkit-router; it is not a universal “before any unmount” callback.
- Identify whether the element is hidden, virtualized, or actually destroyed.
- Check whether editable data belongs in a parent or a service instead of in a disposable child.
- Register lifecycle hooks during script setup, not inside a later click handler.
- Use on_destroy or a returned on_mount cleanup for explicit resource disposal.
Common mistakes
- A <list> row scrolling off-screen does not imply its Python instance, effects, or tasks have been destroyed.
- Do not rely on before_leave to intercept a branch removed by #if.
The window freezes or the layout does not fit
An async def function still runs on the UI thread. A blocking library call inside it can freeze the interface before the next await yields. Put synchronous blocking work behind await background(fn, ...) and assign its returned result on the UI loop. A worker must not mutate state or touch controls.
For layout problems, simplify to a <window> with one <row> or <column>. Check the parent main axis before adding flex={1}; check content minimum sizes before assuming a field will shrink. Unsupported style declarations warn when the rule matches an element; unsupported selectors and at-rules are compile errors. A rule matching nothing may stay silent. Read the supported style subset rather than adding more unrelated rules.
- Run janel build and resolve errors and warnings.
- Reduce the failing behavior to one component and one interaction.
- Keep the terminal open to read script and event exceptions.
- Use janelkit.inspect to write a failing test for the observed bug.
- After the fix, test the initial view, repeated actions, empty values, and teardown.
What you should see
A minimal reproducible example reveals whether the issue is data ownership, invalid syntax, layout constraints, or work blocking the UI. Report the source component and exact diagnostic rather than only a screenshot of the final symptom.
Learn moreStyle reference ↗Testing your application ↗Async work ↗Layout ↗
Check the known limitations before blaming your app
These behaviors have been reproduced in JanelKit 0.2. Keep the reproduction small and include your installed version in a bug report; do not assume a future fix is already available.
| Symptom | Confirmed behavior | Safe next step |
|---|---|---|
| Build passes, window refuses to open | Bare color names are not validated against Qt at compile time | Replace questionable names with hex colors or known theme tokens; mount again. |
| A style rule has no effect and no warning | Rules that match nothing are not checked; a component-name selector such as Card does not style its root | Use a class on the component tag, and check the supported-style reference. |
| A dictionary key changes after restarting | persisted and stores of janelkit-store save JSON, which converts non-text keys to strings | Use string keys before saving; test a save-and-reload round trip. |
| A transition ignores ease-in or a delay | Only the property and duration are used | Use the supported transition form; do not depend on the ignored words. |
Common mistakes
- class="misspelled" and class={...} do not trigger the missing-class warning; that warning currently applies to class:name.
- The missing accessible-name warning is implemented for clickable flex boxes, not every clickable <row> or <column>. Review keyboard access and labels yourself.
Learn moreStyle reference ↗Testing your application ↗Persistence ↗Accessibility and keyboard ↗
Key points
- Start with the exact diagnostic and the stage that produced it.
- Check ownership and lifetime before changing reactive code.
- Compilation, Qt startup, user interactions and packaging need separate checks.
English documentation based on the JanelKit source. For additional details, browse the source docs ↗.