Closed robhogan closed 6 months ago
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 83.83%. Comparing base (
57607bf
) to head (6bd5d2b
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@robhogan merged this pull request in facebook/metro@6856d00cfdddc1dd5ed9ab35249fe7ca1610ca75.
Summary
Add a
server_listening
reporter event. This serves two purposes:Expose actually-bound port and address when input configuration is more ambiguous
Metro may already be configured to start on an ephemeral (OS-assigned) port, if configured with
--port 0
, however Metro doesn't report or expose which port was actually assigned - theinitialize_done
reporter event repeats the configured port.(h/t @kmagiera who let us know about this at React Conf ⚛️)
Similarly, when Metro is configured to start on
localhost
, it doesn't expose whether it binds to IPv6 (potentially dual stack) or (exclusively) IPv4.Report when Metro is first ready to accept HTTP requests
Metro may be listening before the transformer is fully initialised or the file crawl is complete - but this is safe, because request handlers wait for bundler readiness. We may in future start listening earlier in the startup process so that Metro is available to at least start queueing requests as soon as possible.
Integrators may use
server_listening
as an explicit signal that Metro is ready to accept http requests, even though it may not be fully warm.Changelog
Test plan
With
console.log(event)
added toTerminalReporter
forserver_listening
: