Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix promise leak #1403

Merged
merged 1 commit into from Dec 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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