Skip to content

Gracefully handle ErrorKind::BrokenPipe (public-api ... | head -n 1) #94

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

Merged
merged 1 commit into from
May 18, 2022

Conversation

Enselic
Copy link
Owner

@Enselic Enselic commented May 14, 2022

So that we don't get an error when doing something like this:

% RUSTDOCFLAGS='-Z unstable-options --output-format json' cargo +nightly doc  --manifest-path tests/crates/comprehensive_api/Cargo.toml --lib --no-deps
% ./target/debug/public-api tests/crates/comprehensive_api/target/doc/comprehensive_api.json | head -n 1
pub async fn comprehensive_api::functions::async_fn() -> impl Future<Output = ()>
Error: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }

@Enselic
Copy link
Owner Author

Enselic commented May 14, 2022

Hmm maybe we should implement the fix with the #[pipefail] functionality of https://github.com/myrrlyn/calm_io. The test can still be re-used.

Cons:

  • Requires a new dependency, and I try to keep number of dependencies minimal for public-api

Pros:

  • Only one line required to fix the problem (it seems)

For cargo-public-api I'd say it is fine to use the extra dependency. I'll think about it some more (and try it out) for public-api.

So that we don't get an error when doing something like this:

    % RUSTDOCFLAGS='-Z unstable-options --output-format json' cargo +nightly doc  --manifest-path tests/crates/comprehensive_api/Cargo.toml --lib --no-deps
    % ./target/debug/public-api tests/crates/comprehensive_api/target/doc/comprehensive_api.json | head -n 1
    pub async fn comprehensive_api::functions::async_fn() -> impl Future<Output = ()>
    Error: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
@Enselic Enselic force-pushed the handle-broken-pipe branch from fd429b9 to df44eb8 Compare May 17, 2022 20:51
@Enselic
Copy link
Owner Author

Enselic commented May 17, 2022

I found a way that I consider lightweight enough to not warrant an additional dependency. I will think about this for one more day and then merge.

(rust-lang/rust#96647 was just approved so we will need to make a release any day now to keep working with latest nightly)

@Enselic Enselic merged commit 300d0b0 into main May 18, 2022
@Enselic Enselic deleted the handle-broken-pipe branch May 18, 2022 03:54
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