-
Notifications
You must be signed in to change notification settings - Fork 416
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
[WIP] Use --message-format=json
to fix #333
#340
Conversation
src/build.rs
Outdated
.arg("--lib") | ||
.arg("--target=wasm32-unknown-unknown") | ||
.arg("--message-format=json") | ||
.stderr(Stdio::piped()) |
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.
For this I believe it will need to pessimistically spawn a new thread to read stderr. Othrewise the blocking reads on stdout could cause wasm-pack to deadlock when it's waiting for info on stdout but the child is waiting to write info to stderr.
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.
Afaik we're spawning a new process here and stderr is new pipe from the os, so the child can write to stderr no matter what the parent process does (except broken pipe errors and the like). Not an expert though.
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.
Pipes have a fixed capacity, however, and won't infinitely buffer. If Cargo dumps a lot of information on stderr it'll eventually block, and then it won't make progress until the pipe is read, which wasm-pack doesn't do until the process has otherwise finished.
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.
Ah thanks, I didn't think about that! I've replaced the pipe with a tempfile.
0bd1dc7
to
cc38989
Compare
I've rebased onto master. I've realized that rustc and therefore cargo can't do both Because both
|
This was made impossible by #392. |
Parse the
--message-format=json
output with cargo_metadata to get the location of the wasm file from cargo.This PR is marked WIP because it depends on oli-obk/cargo_metadata#53. 7484faf is because I otherwise had test failures about wrong versions (same as for @alexcrichton in #336 (comment)). With that commit
it_can_run_browser_tests
is still failing though. I guess this will be fixed before merging and I can rebase the commit away.Adding
wasm_file
toBuild
is a bit of an ugly solution, but I couldn't come up with something better without rewriting the whole steps code. Currently I'm also ignoring the diagnostics messages and instead return the captured stderr in case of an error. (Not capturing stderr and setting-q
would fix #288 and with the other messages wecould easily do #287. We'd only need to make sure how this interacts with indicatif)Make sure these boxes are checked! 📦✅
rustfmt
installed and have yourcloned directory set to nightly (well, 2018-09-16)
rustfmt
on the code base before submittingCloses #333
Fixes #305
Relevant for #339
✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨