From 4221b90c3febbe03a4b47e47248263741a0fdd4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 14 Oct 2019 23:46:27 +0200 Subject: perf: eager poll async ops in Isolate (#3046) --- cli/lib.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'cli/lib.rs') diff --git a/cli/lib.rs b/cli/lib.rs index 8d0904ddb..3c093cda4 100644 --- a/cli/lib.rs +++ b/cli/lib.rs @@ -298,25 +298,31 @@ fn eval_command(flags: DenoFlags, argv: Vec) { } fn bundle_command(flags: DenoFlags, argv: Vec) { - let (mut _worker, state) = create_worker_and_state(flags, argv); + let (worker, state) = create_worker_and_state(flags, argv); let main_module = state.main_module().unwrap(); assert!(state.argv.len() >= 3); let out_file = state.argv[2].clone(); debug!(">>>>> bundle_async START"); - let bundle_future = state - .ts_compiler - .bundle_async(state.clone(), main_module.to_string(), out_file) - .map_err(|err| { - debug!("diagnostics returned, exiting!"); - eprintln!(""); - print_err_and_exit(err); + // NOTE: we need to poll `worker` otherwise TS compiler worker won't run properly + let main_future = lazy(move || { + worker.then(move |result| { + js_check(result); + state + .ts_compiler + .bundle_async(state.clone(), main_module.to_string(), out_file) + .map_err(|err| { + debug!("diagnostics returned, exiting!"); + eprintln!(""); + print_err_and_exit(err); + }) + .and_then(move |_| { + debug!(">>>>> bundle_async END"); + Ok(()) + }) }) - .and_then(move |_| { - debug!(">>>>> bundle_async END"); - Ok(()) - }); - tokio_util::run(bundle_future); + }); + tokio_util::run(main_future); } fn run_repl(flags: DenoFlags, argv: Vec) { -- cgit v1.2.3