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

Inherit stderr of to subprocesses for debugging #1901

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SimonSapin
Copy link
Contributor

By default Command::output() causes both stdout and stderr to be redirected to separate pipe. If following code does not print stderr this can cause error to be swallowed, making debugging harder.

This changes to inherit stderr instead, so error messages go to Rover’s own stderr.

Example before:

⌛ resolving SDL for subgraphs defined in /tmp/a/rover.yaml
🎶 composing supergraph with Federation v2.7.5
error: Output from `/Users/simon/.rover/bin/supergraph-v2.7.5 compose` was malformed.

Caused by:
    0: /Users/simon/.rover/bin/supergraph-v2.7.5 compose output: 
    1: EOF while parsing a value at line 1 column 0
        This error was unexpected! Please submit an issue with any relevant details about what you were trying to do: https://github.com/apollographql/rover/issues/new/choose

We see that stdout of the subprocess is empty, but we don’t see why.

After, with RUST_BACKTRACE=1 added:

 resolving SDL for subgraphs defined in /tmp/a/rover.yaml
🎶 composing supergraph with Federation v2.7.5
thread 'main' panicked at /Users/distiller/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_v8-0.111.0/de.rs:628:53:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <serde_v8::de::SeqAccess as serde::de::SeqAccess>::next_element_seed
   5: <serde_v8::de::MapObjectAccess as serde::de::MapAccess>::next_key_seed
   6: <serde_json::value::de::<impl serde::de::Deserialize for serde_json::value::Value>::deserialize::ValueVisitor as serde::de::Visitor>::visit_map
   7: <&mut serde_v8::de::Deserializer as serde::de::Deserializer>::deserialize_any
   8: harmonizer::op_composition_result::v8_func
   9: harmonizer::op_composition_result::v8_fn_ptr
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
error: Output from `/Users/simon/.rover/bin/supergraph-v2.7.5 compose` was malformed.

Caused by:
    0: /Users/simon/.rover/bin/supergraph-v2.7.5 compose output: 
    1: EOF while parsing a value at line 1 column 0

[…]

By default `Command::output()` causes *both* stdout and stderr
to be redirected to separate pipe. If following code does not print stderr
this can cause error to be swallowed, making debugging harder.

This changes to inherit stderr instead, so error messages go to Rover’s
own stderr.
@SimonSapin SimonSapin requested a review from a team as a code owner May 7, 2024 15:19
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.

1 participant