From 3da182b0b86d93000d4473188f361ffa2de9fb73 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Sat, 9 Jul 2022 12:49:20 +0300 Subject: fix(ext/ffi): Avoid keeping JsRuntimeState RefCell borrowed for event loop middleware calls (#15116) --- ext/ffi/00_ffi.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js index 2730cae72..22e442e51 100644 --- a/ext/ffi/00_ffi.js +++ b/ext/ffi/00_ffi.js @@ -232,7 +232,9 @@ } unref() { - if (--this.#refcount === 0) { + // Only decrement refcount if it is positive, and only + // unref the callback if refcount reaches zero. + if (this.#refcount > 0 && --this.#refcount === 0) { core.opSync("op_ffi_unsafe_callback_ref", false); } } -- cgit v1.2.3