Why does LiveView send a `cids_will_destroy` event?

I have a live component that keeps getting destroyed after I get the result of an asyn_assign call. This live component has almost nothing to do with the async_result data but for some reason as soon as loading is complete it disappears from the screen. Checking the network tab I see a cids_will_destroy event is sent for that element. I was trying to understand why and when LiveView would send that event.

Some side notes

  • This component has no visibility toggling
  • It only occurs when bundling the app for prod. We can not reproduce it on our local machines.

Are you on the latest version of LiveView? There was a bug recently that led to live components being destroyed: fix live components being destroyed in some circumstances by SteffenDE · Pull Request #2948 · phoenixframework/phoenix_live_view · GitHub

Yes I’m on 0.20.3. Let me know any other information I could provide to you to maybe make the issue clearer.

I‘d say that this definitely sounds like a bug. From my understanding the cids_will_destroy event is sent by the client to tell the server that a live component no longer exists after patching the DOM and can be destroyed. A small example project to reproduce the problem would help dramatically. I would file an issue on GitHub, so that this can be tracked.