`unload()` destroys the app on link clicks that may never navigate

Open
#4,438 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
elixir
Domain
frontend

Research direction

Start by tracing the isNewPageClick path and its synchronous unload(), destroyAllViews, and disconnect calls. Reproduce both the Content-Disposition attachment case and a cancelled beforeunload dialog, then verify teardown occurs only after navigation is confirmed while the cancelled page remains functional.

Written by the indexing model from the issue text.

Description

Environment
  • Elixir version (please paste the output of elixir -v): any

  • Phoenix and LiveView versions (mix deps | grep -w 'phoenix\|phoenix_live_view'): latest

  • Operating system: any
  • Browsers (including version) you attempted to reproduce this bug on (the more the merrier): any

Actual behavior

isNewPageClick synchronously runs unload() (destroyAllViews, disconnect) before navigation is certain. What triggers the bug: a same-origin anchor whose action responds with Content-Disposition: attachment (no download attribute), or the user cancelling a beforeunload dialog on an external link.
Impact: all views destroyed and socket disconnected while a dead page stays on screen

Expected behavior

Tear down once the browser confirms the document is being left

Dominant language
Elixir
Stars
6.8k
Forks
1.1k
Avg merge
1d 3h
Merged PRs (30d)
19

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phoenixframework/phoenix_live_view

All issues in phoenixframework/phoenix_live_view

Similar issues

More Elixir issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.