Task.async before socket redirect?

Hi there. I need to redirect the user from one LiveView to another after they click a button, but also do some work in the background. I don’t need or want to await the completion of the work before redirecting.

However, it seems that Task.async makes the task a child of the current process’s supervision tree. I worry that once I redirect, my first LiveView process is killed, which would stop the async work as well. That’s my hunch for why my work is never started or completed.

If this is true, should I use something else?

The way to avoid that is to use a Task.Supervisor to start the task instead. You’d add one to your application’s supervisor tree and then use Task.Supervisor.start_child to launch tasks into it.