Skip to content

connect_params are lost when navigating #259

@randycoulman

Description

@randycoulman

I'm working on a feature that relies on a value being passed from the browser (app.js) to my LiveView app via the connect_params.

When I test in the browser, all works as expected.

In my tests, I inject a value using Phoenix.LiveViewTest.put_connect_params/2.

When I first visit a live view, the connect_param is present when I call LiveView.get_connect_params/1](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#get_connect_params/1).

However, if I then perform an action that does a live navigation to another LiveView, the connect_params are no longer present.

In the browser, the connect_params persist across all of the live navigation operations as expected.

I believe that the root cause is this call to ConnHandler.recycle_all_headers/1. The recycle it does seems to lose the connect_params.

I haven't tested this with "raw" LiveViewTest, but I see that its follow_redirect implementation (which we also call here) calls ensure_recycled, so it may suffer from the same problem.

Is this something that it makes sense to fix here? Or should I report it upstream to Phoenix instead/as well? Even if it gets fixed there, we'll still have a problem here and vice versa, I think.

I'm not sure of the implications, but I was wondering if the conn should be recycled at all in the case of a :live_redirect, but only in the case of a :redirect. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions