Repository navigation
fix(emulator): show the listen address next to the Emulator UI and Hub links - #11407
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the emulator startup messages to display the correct listening address when the Emulator UI or Hub is configured to listen on a wildcard address (such as 0.0.0.0 or ::). It introduces a new helper function getListenSuffix in commandUtils.ts to format the suffix, integrates it into the startup overview command, and adds corresponding unit tests in commandUtils.spec.ts. There are no review comments, so no feedback is provided.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11407 +/- ##
=======================================
Coverage ? 59.27%
=======================================
Files ? 859
Lines ? 50138
Branches ? 10021
=======================================
Hits ? 29719
Misses ? 18136
Partials ? 2283 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Fixes #6222.
With
"emulators": { "ui": { "host": "0.0.0.0" } }, the Emulator UI listens on 0.0.0.0, but the startup message saysView Emulator UI at http://127.0.0.1:4000/, which looks like the setting was ignored. The table's Host:Port column already shows each emulator's real listen address throughgetListenOverview. The banner link and the "Emulator Hub host:" line go throughEmulatorRegistry.url()/getInfo(), which rewrite wildcard hosts withconnectableHostname()so the link can be opened.This keeps the links connectable and prints the listen address next to them when the two differ:
When an emulator listens on a normal host (127.0.0.1, localhost, a LAN IP), nothing is added, so the default output does not change. The per-emulator "View in Emulator UI" links in the table are unchanged, since they need to be clickable.
The new
getListenSuffix()incommandUtils.tssits next togetListenOverview()and reuses it, so IPv6 wildcards come out bracketed ([::]:4000).Scenarios Tested
commandUtils.spec.ts:getListenSuffixfor 0.0.0.0, the IPv6 wildcard::, hosts that need no suffix (127.0.0.1, a LAN IP), and an emulator that is not running. 15 passing.npx eslinton the three changed files: no errors, and no new warnings on the changed lines.firebase emulators:start --project demo-test6222with the auth emulator, andui.hostandhub.hostset to0.0.0.0infirebase.json:Sample Commands
firebase emulators:startwith"ui": { "host": "0.0.0.0" }infirebase.json.