Skip to content

Commit

Permalink
fix(napi): promise leak
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 authored and Brooooooklyn committed Dec 28, 2022
1 parent bc41c97 commit 742444b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions 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<Option<Runtime>> = Lazy::new(|| {
let runtime = tokio::runtime::Runtime::new().expect("Create tokio runtime failed");
Expand Down Expand Up @@ -73,11 +72,6 @@ pub fn execute_tokio_future<
fut: Fut,
resolver: Resolver,
) -> Result<sys::napi_value> {
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 {
Expand Down

0 comments on commit 742444b

Please sign in to comment.