-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Improve flow starting Metro #613
Closed
szymonrybczak
wants to merge
1
commit into
react-native-community:main
from
szymonrybczak:improve-flow-starting-metro
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: Improve flow starting Metro. | ||
author: | ||
- Szymon Rybczak | ||
date: 2022.03.13 | ||
--- | ||
|
||
# RFC0000: Improve flow starting Metro | ||
|
||
## Summary | ||
|
||
Right now when starting metro and the port is already in use, we'll get an error `Error: listen EADDRINUSE: address already in use :::8081`, which is not very helpful. We should improve this flow, when the port is already in use, we should ask the users if they want to start Metro on another port, or when the bundler for the project is already running, we should inform user about it. | ||
|
||
## Basic example | ||
|
||
<https://user-images.githubusercontent.com/63900941/224777083-91066d8a-0922-4b96-b7ac-c210f2c2d7e5.mp4> | ||
|
||
## Motivation | ||
|
||
This change will improve the developer experience, and will make it easier to start the bundler. All of we know what pain is to search through the terminal windows, and find the window with the running bundler. | ||
|
||
## Detailed design | ||
|
||
### Changes to the Core | ||
|
||
1. Running app from Xcode / Android Studio. During the building process we're starting Metro bundler, and it would be very handy to ask user via prompt to change port if the port is already in use or inform user that bundler is already running for the project. | ||
|
||
### Changes to the CLI | ||
|
||
1. First part of running commands `run-ios` / `run-android` will be to check if bundler is running for the project, if it is, we should inform the user about it. Or if the port is already in use, we should ask the users if they want to start Metro on another port. It would be in the first part because we need to pass `RCT_METRO_PORT` or `-PreactNativeDevServerPort` to the build command. | ||
|
||
## Unresolved questions | ||
|
||
- How we should properly handle the case when running app from Xcode / Android Studio? Is it doable to ask via prompt? | ||
- How could we better handle this on the simulator / emulator side? Right now until we don't type properly port inside DevMenu in simulator / emulator, we won't be able to connect to the bundler. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, coordinating Metro start from a native IDE is done only with Xcode (AFAIK), and this is not terminated when the iOS process ends.
RCT_METRO_PORT
) might be useful but small UX improvement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup we should probably remove them.
IDE integration is delegated to 3rd party plugins. Today is totally doable to just create an IntelliJ plugin that starts/stops Metro or just invoke a command before the "Run" step of the app is triggered.
Ideally we should keep our tools agnostic from the IDE they will end up running into