# Task.async before socket redirect?

**URL:** <https://forum.elixirforum.com/t/task-async-before-socket-redirect/60341>\
**Category:** Questions\
**Tags:** asynchronous, liveview\
**Created:** [December 13, 2023, 4:57pm UTC](https://forum.elixirforum.com/t/task-async-before-socket-redirect/60341 "2023-12-13T16:57:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![al2o3cr](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/32/3457_2.png) [@al2o3cr](https://forum.elixirforum.com/u/al2o3cr)\
**Post date:** [December 13, 2023, 11:41pm UTC](https://forum.elixirforum.com/t/task-async-before-socket-redirect/60341/2 "2023-12-13T23:41:26Z")

</div>

> [@boiserunner](#):
>
> 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.

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`](https://hexdocs.pm/elixir/Task.Supervisor.html#start_child/3) to launch tasks into it.

---

_[View the full topic](https://forum.elixirforum.com/t/task-async-before-socket-redirect/60341)._
