preview.nvim/lua
Barrett Ruth e661ea78e8
fix(reload): bind SSE server to port 0 for OS-assigned port (#21)
Problem: the SSE reload server hardcoded port 5554, causing silent
failure when that port was already in use. bind() would fail but its
return value was never checked; listen() would also error and silently
drop via the if err then return end guard. inject() still wrote the
dead EventSource URL into the HTML, so the browser would connect to
whatever was on 5554 — or nothing — and live reload would silently
stop working.

Solution: bind to port or 0 so the OS assigns a free port, then call
getsockname() after bind to capture the actual port into actual_port.
inject() reads actual_port in preference to the hardcoded constant,
and stop() resets it. PORT = 5554 is kept only as a last-resort
fallback in inject() if actual_port is unset.
2026-03-03 17:46:04 -05:00
..
preview fix(reload): bind SSE server to port 0 for OS-assigned port (#21) 2026-03-03 17:46:04 -05:00