Skip to content

Commit d33bb31

Browse files
committed
try to fix mm2 stop
1 parent 57844da commit d33bb31

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mm2src/mm2_bin_lib/src/mm2_wasm_lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ pub async fn mm2_main(params: JsValue, log_cb: js_sys::Function) -> Result<i8, J
142142
},
143143
};
144144

145+
// This allows context to be properly dropped when stop() is called
146+
let ctx_weak = ctx.weak();
145147
executor::spawn_local(async move {
146-
if let Err(e) = mm2_main::lp_run(ctx).await {
147-
console_err!("MM2 runtime error: {}", e);
148+
if let Some(ctx) = MmArc::from_weak(&ctx_weak) {
149+
if let Err(e) = mm2_main::lp_run(ctx).await {
150+
console_err!("MM2 runtime error: {}", e);
151+
}
148152
}
149153
LP_MAIN_RUNNING.store(false, Ordering::Relaxed);
150154
});

0 commit comments

Comments
 (0)