dashboard: Fix occasional "unexpected action" applet errors on startup

This turned out to be a race between the dashboard's dataset db
subscriber being initialised and the applet "embed" request, with
artiq.applet.simple not being able to handle the unexpected "mod"
message. We were only handling the other ordering outcome of this
race before.
This commit is contained in:
David Nadlinger 2023-09-30 00:14:30 +01:00
parent a772dee1cc
commit 2eb89cb168
1 changed files with 7 additions and 0 deletions

View File

@ -51,6 +51,13 @@ class AppletIPCServer(AsyncioParentComm):
def _on_mod(self, mod): def _on_mod(self, mod):
if mod["action"] == "init": if mod["action"] == "init":
if not (self.datasets or self.dataset_prefixes):
# The dataset db connection just came online, and an applet is
# running but did not call `subscribe` yet (e.g. because the
# dashboard was just restarted and a previously enabled applet
# is being re-opened). We will later synthesize an "init" `mod`
# message once the applet actually subscribes.
return
mod = self._synthesize_init(mod["struct"]) mod = self._synthesize_init(mod["struct"])
else: else:
if mod["path"]: if mod["path"]: