Known pitfalls and fixes
This page records what the "written but never run" call sugar turned into once a real dependency exercised it. Every entry is symptom → root cause → fix, so you can match it against older code or a similar problem.
JavaScript side
await Axon.Ctl.prop never resolves (old version)
- Symptom:
await Axon.TestController.counterhangs, the Promise never settles;.then(cb)works fine. - Cause: in
Axon.tsthe object literal memberthen: () => {...}was an arrow function, so it ignoredthen's two arguments and the resolve value could never be delivered (awaitrelies on exactly that). - Fix:
then(onFulfilled, onRejected) { return promise.then(onFulfilled, onRejected) }, same forcatch/finally.
AxonInit() throws in a plain browser
- Symptom: with no Qt channel the page goes blank, console shows
TypeError: Cannot read properties of undefined. - Cause:
initChannels()only logged on failure and resolved anyway; the followingAxonPYCallHandler.init()then readAxonChannels.AxonPYCalland blew up, so the caller had no way to know whether a backend existed. - Fix:
initChannels()returnsIAxonChannelStatusandAxonInit()returns{connected, ready, reason, objects, error}; with no channel it returnsready: falseinstead of throwing. The documentation site's two modes switch on that value.
The second @AxonController() reuses the first class name
- Symptom: with two classes using the default id, the second overwrote the first and JS could not reach it.
- Cause: the decorator closure rewrote
idviaif (id === undefined) id = controller.name, so on the second callidwas no longer undefined. - Fix:
const controllerId = id !== undefined ? id : controller.name.
Qt event names did not match
- Symptom:
AxonEvent.addListener("dragMove", ...)/"dragLeave"never fired. - Cause: Python dispatches
"dragMove"/"dragLeave"(AxonGUI.py) while the JS typings declared"dragMoveEvent"/"dragLeaveEvent". - Fix: use Python's short names;
AxonQtEventMapwas updated to match.
Python side
Axon("w").Ctl raises RecursionError
- Symptom:
ax = Axon("w1"); ax.JSCallPYController→maximum recursion depth exceeded. - Cause:
JSController.__init__assignedself.web_name, which went through__setattr__→setVar→__getattr__→ readself.web_name→ recursion. - Fix: use
object.__setattr__inside__init__;__setattr__only sendssetVarand stores the Future in_last_future(the old.result()deadlocked on the main thread).
await Axon(w).Ctl.prop raises TypeError: __await__() returned non-iterator
- Cause:
__await__returnedfuture.result(), i.e. a value, not an iterator. - Fix:
return asyncio.wrap_future(self._ensure_get()).__await__().
Cannot await a callback Future on the Python side
- Symptom:
await Axon(w).JSBridge.echo("hi")→TypeError: object Future can't be used in 'await' expression. - Cause:
concurrent.futures.Futuredoes not implement__await__. - Fix: add
AxonFuture(Future)with__await__ = asyncio.wrap_future(self).__await__();_callreturns it.
The decorator registered only the first window
- Symptom: after
@AxonController(["webA", "webB"])onlywebAcould reach the controller. - Cause:
return clssat inside thefor web_name in web_namesloop. - Fix: return after the loop.
A new window cannot find the AxonEvent controller
- Symptom: after
dispatchPYEventno Python listener fired; Python loggedRuntimeError: Controller AxonEvent of Web testWeb not found. - Cause:
AxonEventis an instance registered to"*"(AxonController.register(AxonEvent, id="AxonEvent")), butauto_registeronly merged the class registry, so instance entries under"*"were not inherited by windows created later. - Fix: add
globalControllerstoAxonJSCallHandler;register(..., "*")records into it andauto_register(web)applies global instances before class instances.
Dispatching loadFinished immediately loses the event
- Symptom: the counter is
0on first load and only works after a refresh. - Cause: Qt's
loadFinishedfires before the frontend handshake, so JS'sAxonPYCall.onCallSignalwas not connected yet and the message went nowhere. - Fix: report in both directions. After initialisation JS calls
AxonEnv.ready()(a new@Slot()), andAxonGUIwaits for_page_loaded+_js_ready+_load_finished_dispatchedbefore dispatching once viaQTimer.singleShot(0, ...).
AxonStore ids got doubly wrapped
- Symptom: after
new AxonStore("demo")the JS map key became__AxonStore___AxonStore_demo____. - Cause: Python passed
self.controller_idtocreateStore, while JS treats the argument as the store id. - Fix: pass
self.id.
AxonStore.shared cannot add windows
- Symptom:
AttributeError: 'dict_keys' object has no attribute 'append'. - Cause:
SharedAxonStore.web_namesis a read-only property (it returnsAxonGUI.get_web_names()), but the inheritedadd_webcalledappendon it. - Fix: use
self._web_namesinternally;SharedAxonStore.web_namesreturnslist(...).
Python writes to the Store do not reach JS
- Symptom: after
store.foo = 1, JSprop("foo").get()still returns the old value. - Cause:
AxonStoreProperty.__set__was dead descriptor code (no class attribute referenced it), andAxonStoreBase.__setattr__wrote every attribute straight into__dict__. - Fix:
AxonStorePropertybecame a plain object with_value+get()/set()/setFromPeer()/value, andAxonStoreBase.__setattr__routes non-reserved names toself.prop(name).set(value).
AxonMagicGUI.run() raises AttributeError: instance
- Cause:
instance: "AxonMagicGUI | None"was only a type annotation; no class attribute existed. - Fix: explicit
instance: AxonMagicGUI | None = None, andrun()checksis None.
Page loads before QWebChannel is attached (race)
- Symptom: intermittent
qt init fail, cured by a refresh. - Cause:
AxonWebEngineView.__init__calledself.load(url)first, thensetWebChannel()and the seven settings. - Fix: move
load()to the end of initialisation.
Environment
libxkbfile1is required, otherwiseimport axonfails withImportError(AxonEngineViewimportsQtWebEngineCore, which needs the system library).- Running the harness headless needs
QT_QPA_PLATFORM=offscreenandQTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox --disable-gpu --disable-dev-shm-usage". - Timers are throttled when the window is invisible: offscreen,
setTimeout(100)measured ~400 ms, so "timeout" tests must give the server-side sleep at least 3× headroom.
Pitfalls from building this site's example UI
- Swapping the button node with
v-if/v-elsefools automation: after expansion the run button became a different<button>, the old node the script held stayeddisabled = false, and the script read the flow before the example finished, producing an empty conclusion line. Fix: keep one node and only change its label and disabled state. runJavaScriptcallbacks cannot carry JS objects: returning{a:1}yields an empty/unusable value in PySide6;JSON.stringifyfirst andjson.loadson the Python side.- Do not express "no backend" with a disabled button: disabling still requires the reader to understand why, and that sentence is meaningless on a static site. Instead, UI that needs the backend renders only when
connectedis true, so in web mode that block simply does not exist.
A project generated by a packaged axon-gui init was incomplete
- Symptom: after
pip install axon-gui, runningaxon-gui init myappproduced a project with novendor/axon-core/dist(and novendor/axon-py);npm installfailed withTS2307: Cannot find module 'axon-gui'. - Cause:
cli.pyonly vendored when the package lived inside the repository; the installed-package branch copied the template only. - Fix: merge both branches — outside the repo, download the GitHub archive and vendor
template/+core-js/+core-py/the same way; commitcore-js/dist(CI checks it matcheslib/), and fall back to the matching prebuilt npm tarball when the archive has nodist.
White page after packaging as a windowed exe (ERR_EMPTY_RESPONSE)
- Symptom: double-clicking
AxonDocs.exeopens the window with the right title, but the content area showsThis page isn't working / 127.0.0.1 didn't send any data / ERR_EMPTY_RESPONSE. Development mode (python docs/main.py) is fine, and CI's--smokeis green. - Cause: a windowed build (PyInstaller
--windowed) has no console, sosys.stderrisNone; yetSimpleHTTPRequestHandlercallslog_message()for every request, and the old implementation wrote directly withsys.stderr.write(...). Every request raisedAttributeErrorat the logging step and the connection was dropped — the browser sees "the server sent no data". CI's--smokeruns in a shell with a console, wherestderrexists, so it passed. - Reproduce without packaging:python
sys.stderr = None # simulate a windowed exe urllib.request.urlopen(url) # old implementation -> RemoteDisconnected - Fix: null-safe logging in
docs/server.py(plusAXON_DOCS_LOG=pathto write a file), andhandle_one_request()catches handler exceptions and answers 500 instead of dropping the connection.
Client window "absurdly large" / "very slow first start"
- Window: the code hard-coded
view.resize(1280, 840). A 1280×800 VM or a 1080p laptop at 125–150% scaling is smaller than that, so the window overflowed the screen and the title bar was pushed off it. Fix: shrink to 94% ofscreen.availableGeometry()and centre it (docs/main.py: fit_to_screen). - Startup: PyInstaller
--onefileunpacks 200+ MB into%TEMP%\_MEIxxxxon every launch and then waits for Defender to scan it, so cold start is inevitably slow. Fix: use the directory layout (--onedir, now the default) so the exe and dependencies stay in place and start instantly;--onefileremains an explicit option.