Skip to content

Commit

Permalink
Merge pull request #96 from bulwark-security/fix-io-flush
Browse files Browse the repository at this point in the history
Flush IO after every handler runs
  • Loading branch information
sporkmonger authored Jul 31, 2023
2 parents 6cb214c + d931260 commit d201bc9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/wasm-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,20 @@ fn {}() -> Result {{
// basic error handling on the result
#[inline(always)]
#inner_fn
#name().map_err(|e| {
let result = #name().map_err(|e| {
eprintln!("error in '{}' handler: {}", #name_str, e);
append_tags(["error"]);
// Absorbs the error, returning () to match desired signature
})
});
#[allow(unused_must_use)]
{
// Apparently we can exit the guest environment before IO is flushed,
// causing it to never be captured? This ensures IO is flushed and captured.
use std::io::Write;
std::io::stdout().flush();
std::io::stderr().flush();
}
result
}
}
}
Expand Down

0 comments on commit d201bc9

Please sign in to comment.