TypeError when a race condition occurs in the WorkerActivity state watcher
Sentry Issue: ARKINDEX-FRONTEND-AX7
TypeError: n is undefined
at mt.watch.initialTasks (./src/views/Process/Status.vue:247:11)
...
(2 additional frame(s) were not displayed)
When a process is set to ActivityState.Pending
, the process status page uses a watcher on the tasks without parents of the current workflow to deduce when this state switches to Ready
, which sheds some extra API requests. The initialTasks
computed property, which returns the tasks without parents, can return undefined
when there are no known tasks at all, or when the last run number of the process is not known (it is deduced from the known tasks anyway).
With the recent change to avoid the extra automatic redirect to run 0 when we know we will be on run 0, a race condition can occasionally occur where the initialTasks
computed property is evaluated too early, before the first API request to fetch the Ponos tasks completes, causing it to send a undefined
to the watcher and causing this TypeError.
This was not noticed before, because the automatic redirect code has to wait for the process to load its tasks before redirecting to the last run (otherwise, it would not know which run is the last one). The initialTasks
property is then only evaluated after the redirect, when the tasks are already loaded.