From e293c204a07f5a7a862e835f8a5f54f5435f8b91 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 10 Sep 2018 14:12:52 -0400 Subject: [PATCH] Support async futures that have empty response. --- src/handlers.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/handlers.rs b/src/handlers.rs index 586f3dbbf0..2fff5a06f1 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -97,13 +97,20 @@ pub extern "C" fn msg_from_js(d: *const DenoC, buf: deno_buf) { let future = future.and_then(move |maybe_box_u8| { let buf = match maybe_box_u8 { Some(box_u8) => deno_buf_from(box_u8), - // Send back null deno_buf. - None => deno_buf { - alloc_ptr: 0 as *mut u8, - alloc_len: 0, - data_ptr: 0 as *mut u8, - data_len: 0, - }, + None => { + // async RPCs that return None still need to + // send a message back to signal completion. + let builder = &mut FlatBufferBuilder::new(); + deno_buf_from( + serialize_response( + cmd_id, + builder, + msg::BaseArgs { + ..Default::default() + }, + ).unwrap(), + ) + } }; // TODO(ry) make this thread safe. unsafe { libdeno::deno_send(d, buf) };