diff --git a/src/compiler/rust/canister/src/ic/call_raw.rs b/src/compiler/rust/canister/src/ic/call_raw.rs index 46e830bae2..b8968fcb21 100644 --- a/src/compiler/rust/canister/src/ic/call_raw.rs +++ b/src/compiler/rust/canister/src/ic/call_raw.rs @@ -93,9 +93,8 @@ impl JsFn for NativeFunction { reject.call(&[js_value.clone()]); } - // TODO do we need to progress setTimeouts and stuff? - // TODO make sure to test this - // context.event_loop().unwrap().run_tick_task(); + // TODO Is this all we need to do for promises and timeouts? + context.event_loop().unwrap().run_tick_task(); context.promise_loop_poll(); }); }); diff --git a/src/compiler/rust/canister/src/ic/call_raw128.rs b/src/compiler/rust/canister/src/ic/call_raw128.rs index de3819f07a..06c8fa9986 100644 --- a/src/compiler/rust/canister/src/ic/call_raw128.rs +++ b/src/compiler/rust/canister/src/ic/call_raw128.rs @@ -93,9 +93,8 @@ impl JsFn for NativeFunction { reject.call(&[js_value.clone()]); } - // TODO do we need to progress setTimeouts and stuff? - // TODO make sure to test this - // context.event_loop().unwrap().run_tick_task(); + // TODO Is this all we need to do for promises and timeouts? + context.event_loop().unwrap().run_tick_task(); context.promise_loop_poll(); }); }); diff --git a/src/compiler/rust/canister/src/ic/set_timer.rs b/src/compiler/rust/canister/src/ic/set_timer.rs index aa724a2b9a..c231ccde2a 100644 --- a/src/compiler/rust/canister/src/ic/set_timer.rs +++ b/src/compiler/rust/canister/src/ic/set_timer.rs @@ -40,6 +40,10 @@ impl JsFn for NativeFunction { timer_callback.call(&[]); + // TODO Is this all we need to do for promises and timeouts? + context.event_loop().unwrap().run_tick_task(); + context.promise_loop_poll(); + // TODO handle errors }); }); diff --git a/src/compiler/rust/canister/src/ic/set_timer_interval.rs b/src/compiler/rust/canister/src/ic/set_timer_interval.rs index 6394080b6a..d075914d2c 100644 --- a/src/compiler/rust/canister/src/ic/set_timer_interval.rs +++ b/src/compiler/rust/canister/src/ic/set_timer_interval.rs @@ -40,6 +40,10 @@ impl JsFn for NativeFunction { timer_callback.call(&[]); + // TODO Is this all we need to do for promises and timeouts? + context.event_loop().unwrap().run_tick_task(); + context.promise_loop_poll(); + // TODO handle errors }); }); diff --git a/src/compiler/rust/canister/src/lib.rs b/src/compiler/rust/canister/src/lib.rs index 53d6353283..01ca7cc7c5 100644 --- a/src/compiler/rust/canister/src/lib.rs +++ b/src/compiler/rust/canister/src/lib.rs @@ -109,8 +109,9 @@ fn execute_js(function_name: &str, pass_arg_data: bool) { _ => {} }; - // TODO might we need to do this in init and post_upgrade? + // TODO Is this all we need to do for promises and timeouts? context.event_loop().unwrap().run_tick_task(); + context.promise_loop_poll(); }); }); } diff --git a/src/compiler/rust/canister_methods/src/lib.rs b/src/compiler/rust/canister_methods/src/lib.rs index 9028721c3f..affc339726 100644 --- a/src/compiler/rust/canister_methods/src/lib.rs +++ b/src/compiler/rust/canister_methods/src/lib.rs @@ -63,6 +63,11 @@ pub fn canister_methods(_: TokenStream) -> TokenStream { context.eval_global_str("globalThis.exports = {};".to_string()); context.eval_module_str(std::str::from_utf8(MAIN_JS).unwrap().to_string(), "azle_main"); + + // TODO Is this all we need to do for promises and timeouts? + context.event_loop().unwrap().run_tick_task(); + context.promise_loop_poll(); + // let temp = context.eval_module_str(std::str::from_utf8(MAIN_JS).unwrap().to_string(), "azle_main"); // match &temp { @@ -109,6 +114,11 @@ pub fn canister_methods(_: TokenStream) -> TokenStream { context.eval_global_str("globalThis.exports = {};".to_string()); context.eval_module_str(std::str::from_utf8(MAIN_JS).unwrap().to_string(), "azle_main"); + + // TODO Is this all we need to do for promises and timeouts? + context.event_loop().unwrap().run_tick_task(); + context.promise_loop_poll(); + // let temp = context.eval_module_str(std::str::from_utf8(MAIN_JS).unwrap().to_string(), "azle_main"); // match &temp {