title: Start and monitor celery work-flows from Node.js API
body: <h2>Background</h2>
  <p>I am building a system that will perform lengthy file operations on demand. I'm thinking of having a few containers running Celery to perform the tasks. Because of the task complexity, I'm thinking of using some work-flow primitives, like group, chain and map. This will allow me to have simpler tasks, more granular retry and error handling (I believe). I will also use the <a href="https://flower.readthedocs.io/en/latest/api.html" rel="nofollow noreferrer">Flower API</a>.</p>
  <h2>The issue</h2>
  <p>The way I'm planning to kick off the tasks is via a Node.js API (using express), which means I can't use the client part of Celery, where the work-flow primitives are usually used. I was thinking of starting tasks using the Flower API.</p>
  <p>I thought I could define a root task that itself starts a chain of other tasks, like this:</p>
  <pre class="lang-py prettyprint-override"><code>@app.task(track_started=True)
  def A(arg):
      perform_file_task(arg)
  
  
  @app.task(track_started=True)
  def B(arg):
      perform_second_file_task(arg)
  
  
  @app.task(track_started=True)
  def root_task(arg):
      chain = (A.si(arg) | B.se(arg))
  
      chain()
  </code></pre>
  <p>This is how the <a href="https://docs.celeryq.dev/en/latest/userguide/tasks.html#avoid-launching-synchronous-subtasks" rel="nofollow noreferrer">Celery docs</a> also suggest calling tasks from other tasks.</p>
  <p>However, when I start <code>root_task</code>, even if <code>A</code> or <code>B</code> fails, the root task does not. To check whether the subtasks succeeded I have to use the <a href="https://flower.readthedocs.io/en/latest/api.html#get--api-task-info-(.*)" rel="nofollow noreferrer">task info</a> endpoint and follow the <code>children</code> field of the response to reconstruct the task tree and check each one. However, that seems excessive and impractical.</p>
  <p>I know I can use python client side, which can take care of all that (if I define the chain client side and call <code>result.get()</code> on the result, but I don't have python on the client side. Furthermore, the Celery docs discourage calling <code>.get()</code> in a task.</p>
  <p>Is there a better way to run a task chain and check if everything succeeded in a succint way?</p>