Add server_listening reporter event with actually-bound port and address #1274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
: