mtrudel/bandit

Using Process.send_after or :timer.send_interval generates error after liveview process is dead

Closed this issue · 1 comments

I noticed that if I use Process.send_after or :timer.send_interval inside a LiveView and then reload or leave the page, I will get the following error:

[error] Bandit.HTTP1.Handler #PID<0.985.0> received unexpected message in handle_info/2: :tick

Note: In this case :tick is the event that either functions are generating.

I believe this is a dupe of #84, #92, #141 and #218. #141 has the best description of what's going on, but the issue is that your mount code needs to discriminate on the value of connected? since LiveView calls this function at two places in the connection lifecycle. I assume that you're calling the send_after / send_interval function from within an unconnected liveview initially, so self() is going to be the Bandit handler process, even after the liveview life cycle completes.

Closing this issue for hygiene. If the above is not in fact the case, please feel free to reopen it!