The thread-safe function's finalizer is not called in conjunction with the garbage collection of a JS value. In fact, it keeps a strong reference to the JS function it is expected to call. Thus, it is safe to make calls that affect GC state from its body. PR-URL: https://github.com/nodejs/node/pull/51801 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>