From f88b90f71ef0367282c807bd9c1de227e5879aa1 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 23 Jul 2024 15:08:13 +0200 Subject: [PATCH] fix(napi-derive): call flush on the BufWriter (#2195) This is mandated by the Rust doc of the BufWriter. We've also seen bugs where the data doesn't seem to be flushed properly, and thus the CLI fails to parse JSONs emitted by napi-derive. This might be it, or not, but flushing shouldn't hurt. --- crates/macro/src/expand/napi.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/macro/src/expand/napi.rs b/crates/macro/src/expand/napi.rs index e56c3046..608321bc 100644 --- a/crates/macro/src/expand/napi.rs +++ b/crates/macro/src/expand/napi.rs @@ -149,7 +149,8 @@ fn output_type_def(napi: &Napi) { .and_then(|file| { let mut writer = BufWriter::::new(file); writer.write_all(type_def.to_string().as_bytes())?; - writer.write_all("\n".as_bytes()) + writer.write_all("\n".as_bytes())?; + writer.flush() }) .unwrap_or_else(|e| { println!("Failed to write type def file: {:?}", e);