Skip to content
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

Modify line reader to always consume stderr and mark stderr in callback #560

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

kmagiera
Copy link
Member

This PR modifies the behavior of lineReader which would previously only tried on reading from stderr when requested.

Since typically stderr is used to pass on important information and given almost all uses in out codebase would set stderr as true, this method now connects to stderr by default.

For the use-cases where we want to be able to tell whether line comes from stderr or stdout (like with the sim-server stdout that is used as communication and control channel), the line callback gets an additional argument that indicates whether line comes from stderr.

Test plan

Run expo-router, try clean rebuild on Android and iOS

Copy link

vercel bot commented Sep 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 8:09am

Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved, left one question inline

throw new Error("Child process has no stdout");
export function lineReader(childProcess: ExecaChildProcess<string>) {
if (!childProcess.stdout) {
throw new Error("Child process doesn't have stdout");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible for the process to not have stdout but have stderr? If so and if we decide that stderr should be passed on by default, maybe it would be useful to allow line reader to exist without stdout?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only possible if the process is configured to pipe stdout. We typically use lineReader to read from stdout hence it crashes if stdout is not present. If we ever need to reac stderr and not stdout we may need to change this function to support such usecase.

@kmagiera kmagiera merged commit 8f63403 into main Sep 19, 2024
3 checks passed
@kmagiera kmagiera deleted the kmagiera/stderr-readline branch September 19, 2024 08:21
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.

3 participants