From ce4c28412a202e3ceacd2002bbf53be06260fa65 Mon Sep 17 00:00:00 2001 From: Xiaopeng Li Date: Thu, 29 Dec 2022 00:15:55 +0800 Subject: [PATCH] fix(napi): promise leak (#1403) Co-authored-by: Xiaopeng Li --- crates/napi/src/tokio_runtime.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/napi/src/tokio_runtime.rs b/crates/napi/src/tokio_runtime.rs index ef923ac5..a024bf38 100644 --- a/crates/napi/src/tokio_runtime.rs +++ b/crates/napi/src/tokio_runtime.rs @@ -1,10 +1,9 @@ use std::future::Future; -use std::ptr; use once_cell::sync::Lazy; use tokio::runtime::Runtime; -use crate::{check_status, sys, JsDeferred, JsUnknown, NapiValue, Result}; +use crate::{sys, JsDeferred, JsUnknown, NapiValue, Result}; pub(crate) static mut RT: Lazy> = Lazy::new(|| { let runtime = tokio::runtime::Runtime::new().expect("Create tokio runtime failed"); @@ -73,11 +72,6 @@ pub fn execute_tokio_future< fut: Fut, resolver: Resolver, ) -> Result { - let mut promise = ptr::null_mut(); - let mut deferred = ptr::null_mut(); - - check_status!(unsafe { sys::napi_create_promise(env, &mut deferred, &mut promise) })?; - let (deferred, promise) = JsDeferred::new(env)?; spawn(async move {