Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LiveView event to context only during exceptions #78

Merged
merged 2 commits into from
Sep 1, 2024

Conversation

crbelaus
Copy link
Contributor

As @odarriba and @numso discussed on #74 the current approach of adding LiveView event information to the process context may result in misleading information for certain errors.

For example, if the following happened:

  1. mount the liveview
  2. handle_event("something", params, socket) in the liveview
  3. handle_info("something_else", socket) causing a re-render
  4. render -> exception occurs

I think live_view.event and live_view.event_params would still be in the error context when the exception was reported. They would have been assigned to context in step 2. But by step 4, that data could be irrelevant. Am I understanding that right?

This pull request adds the LiveView event information to the context only during exceptions and avoids the situations mentioned above. The LiveView name, URL and URL params are still part of the process context as that information is helpful to understand what was going on before the error happened.

This is consistent with the LiveComponent error handled implemented in #74

Copy link
Contributor

@odarriba odarriba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@odarriba odarriba merged commit c66e452 into main Sep 1, 2024
3 checks passed
@odarriba odarriba deleted the improve-live-view-context branch September 1, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants