Skip to content

Fix LongPoll transport name in sessionStorage and logs#6562

Merged
chrismccord merged 1 commit intophoenixframework:mainfrom
rhcarvalho:preserve-longpoll-transport-name-minification
Feb 2, 2026
Merged

Fix LongPoll transport name in sessionStorage and logs#6562
chrismccord merged 1 commit intophoenixframework:mainfrom
rhcarvalho:preserve-longpoll-transport-name-minification

Conversation

@rhcarvalho
Copy link
Contributor

@rhcarvalho rhcarvalho commented Dec 16, 2025

Projects created with mix phx.new enable JavaScript minification by default in production. This renames symbols to reduce code size, including the LongPoll transport class name.

As a result, when the Socket falls back to LongPoll, it stores something like phx:fallback:Jt in sessionStorage instead of the expected phx:fallback:LongPoll (as it does in development).

The shortened name is not guaranteed to be stable across builds, leading to unintended behavior when deploying new versions of an app.

The transport name was also used in log messages, which now will also preserve the correct LongPoll name.

image

Projects created with `mix phx.new` enable JavaScript minification by
default in production. This renames symbols to reduce code size,
including the LongPoll transport class name.

As a result, when the Socket falls back to LongPoll, it stores something
like `phx:fallback:Jt` in sessionStorage instead of the expected
`phx:fallback:LongPoll` (as it does in development).

The shortened name is not guaranteed to be stable across builds, leading
to unintended behavior when deploying new versions of an app.

The transport name was also used in log messages, which now will also
preserve the correct LongPoll name.
@rhcarvalho
Copy link
Contributor Author

Open to suggestions on what would be useful automated tests for this.

I looked at assets/test/socket_test.js quickly, didn't find tests that would exercise the logger to a point that could expose the problem. Also found nothing on the interaction with sessionStorage.

Note LongPoll.name falls apart only when the source is minified, so that is yet another thing tests would need to replicate.

@chrismccord chrismccord merged commit 636acb0 into phoenixframework:main Feb 2, 2026
6 checks passed
@chrismccord
Copy link
Member

❤️❤️❤️🐥🔥

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.

3 participants