From 814fe22b4c7473f833127878fa08331b42c137cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Thu, 29 Jan 2026 15:52:04 +0100 Subject: [PATCH] fix(js): adjust `external_memory_size` on `Impit` instantiation --- impit-node/src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/impit-node/src/lib.rs b/impit-node/src/lib.rs index e33ce934..244087c2 100644 --- a/impit-node/src/lib.rs +++ b/impit-node/src/lib.rs @@ -5,7 +5,7 @@ use impit::{ impit::{Impit, ImpitBuilder}, request::RequestOptions, }; -use napi::Env; +use napi::{bindgen_prelude::ObjectFinalize, Env}; use napi_derive::napi; mod abortable_stream; @@ -37,11 +37,18 @@ use request::{HttpMethod, RequestInit}; /// /// Note that all the requests made by this instance will share the same configuration, /// resources (e.g. cookie jar and connection pool), and other settings. -#[napi(js_name = "Impit")] +#[napi(js_name = "Impit", custom_finalize)] pub struct ImpitWrapper { inner: Impit, } +impl ObjectFinalize for ImpitWrapper { + fn finalize(self, env: Env) -> napi::Result<()> { + env.adjust_external_memory(-500 * 1024)?; + Ok(()) + } +} + #[napi] impl ImpitWrapper { /// Creates a new `Impit` instance with the given options. @@ -66,6 +73,8 @@ impl ImpitWrapper { let config: Result, napi::Error> = options.unwrap_or_default().into_builder(env); + let _ = env.adjust_external_memory(500 * 1024); + // `quinn` for h3 requires existing async runtime. // This runs the `config.build` function in the napi-managed tokio runtime which remains available // throughout the lifetime of the `ImpitWrapper` instance.