Skip to content

web: --port 0 now works in --serve-browse mode too - #2723

Open
acinader wants to merge 1 commit into
plaintextaccounting:mainfrom
acinader:web-browse-port0
Open

web: --port 0 now works in --serve-browse mode too#2723
acinader wants to merge 1 commit into
plaintextaccounting:mainfrom
acinader:web-browse-port0

Conversation

@acinader

@acinader acinader commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

--port 0 (#2559, let the OS choose a free port) now works in the default --serve-browse mode as well.

Follows #2722, now merged.

Prior to #2722 we errored when trying to get the OS to assign a port in --serve-browse mode, because the browser launcher of the time, wai-handler-launch, had to be given a port number up front. Since #2722, hledger-web runs warp itself in that mode, so it can serve on the socket it already bound to the OS-chosen port, exactly as --serve does, and open the browser at the base url built from that port. This removes the exception and its error message, and the manual's and changelog's caveats about it.

The browse-mode browser spec now starts its server with --port 0 rather than on a fixed port, and its launcher stub records the url it is asked to open, so the spec also checks that the browser is opened at the chosen port. To support that, the suite's one server starter now reads the url from the startup banner, for both of its callers, and keeps the server's output so that a failure to start is reported with its message.

AI usage: Claude Fable 5.1, ~8k output tokens; the commit message and this description were reviewed and edited by me before publishing.

@acinader

acinader commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I'll stop with the infrastructure stuff now. Running claude's /code-review on this revealed some changes to make in #2722 which I put in commit: 6ba0045

@acinader

acinader commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I am switching to using this for my work so I can dog food test the keep alive and the port 0 stuff.

--port 0 (let the OS choose a free port, plaintextaccounting#2559) was refused in browse
mode because wai-handler-launch had to be given a port number up front.
Now that hledger-web runs warp itself in that mode, it can serve on the
socket it already bound to the chosen port, exactly as --serve does,
and open the browser at the base url built from that port.

The browse-mode browser spec now starts its server with --port 0
instead of on a fixed port 5089, and its launcher stub records the url
it is given, so the spec also checks that the browser is opened at the
chosen port. To support that, the suite's one server starter now reads
the url from the startup banner (and keeps the server's output, so a
failure to start is reported with its message) for both of its callers.

AI usage: Claude Fable 5.1, ~8k output tokens
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.

1 participant