Skip to content

fix: remove the hardcoded 750ms LiveView latency simulator in dev - #3901

Closed
chasers wants to merge 3 commits into
mainfrom
fix/remove-dev-latency-sim
Closed

chasers wants to merge 3 commits into
mainfrom
fix/remove-dev-latency-sim

Conversation

@chasers

@chasers chasers commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Problem

The dev root layout called liveSocket.enableLatencySim(750) on every page load:

<%= if Application.get_env(:logflare, :env) == :dev do %>
  <script>
    window.liveSocket.enableLatencySim(750)
  </script>
<% end %>

LiveView then delayed every client message by 750ms:

let latency = this.getLatencySim()
if(!latency){ cb(data) } else { setTimeout(() => cb(data), latency) }

So every click, every phx-change, and every form submit paid 750ms in dev.

Evidence

The server was never slow. Measured on this codebase:

Measurement Result
change_form_type server render 0.5ms median, 9 KB payload
LiveView mounts (dead render) 6-21ms
Callbacks over 100ms none

Selecting a backend type renders in 0.5ms, then waits 750ms in the browser.

Side effect this also fixes

enableLatencySim calls enableDebug() first, so dev also logged every LiveView event to the console.

After merging

The value persists in sessionStorage, so removing the script does not clear it. Run this once in the browser console:

liveSocket.disableLatencySim()

Opening a new tab also works.

A developer who wants the simulator can still call liveSocket.enableLatencySim(750) from the console.

🤖 Generated with Claude Code

https://claude.ai/code/session_015XJWSbFFxwiYB25iUAGmXc

The dev root layout called `liveSocket.enableLatencySim(750)` on every page.
LiveView then delayed every client message by 750ms through `setTimeout`, so
each interaction felt slow. Selecting a backend type renders in 0.5ms on the
server, but took 750ms in the browser.

`enableLatencySim` also turns on debug mode, which logs every event to the
console.

A developer who wants the simulator can still call
`liveSocket.enableLatencySim(750)` from the console.

Note: the setting persists in sessionStorage. Run `liveSocket.disableLatencySim()`
once, or open a new tab, to clear an existing value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015XJWSbFFxwiYB25iUAGmXc
@chasers

chasers commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing for #3986 3986

@chasers chasers closed this Sep 14, 2026
chasers added a commit that referenced this pull request Sep 17, 2026
The dev root layout called `liveSocket.enableLatencySim(750)` on every page
load. LiveView then held back every client message by 750ms, so every click
and form change in dev waited 750ms. The server was never slow.

This is the same change as #3901.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBPF1knvgfghTSdxuYryGL
chasers added a commit that referenced this pull request Sep 17, 2026
The dev root layout called `liveSocket.enableLatencySim(750)` on every page
load. LiveView then held back every client message by 750ms, so every click
and form change in dev waited 750ms. The server was never slow.

This is the same change as #3901.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBPF1knvgfghTSdxuYryGL
chasers added a commit that referenced this pull request Sep 17, 2026
The dev root layout called `liveSocket.enableLatencySim(750)` on every page
load. LiveView then held back every client message by 750ms, so every click
and form change in dev waited 750ms. The server was never slow.

This is the same change as #3901.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBPF1knvgfghTSdxuYryGL
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