deno
aa6ee7d5 - fix(ext/napi): call wrap/ref finalizers at shutdown (#32592)

Commit
139 days ago
fix(ext/napi): call wrap/ref finalizers at shutdown (#32592) - Track NAPI finalizer callbacks (from `napi_wrap`, `napi_create_external`, `napi_add_finalizer`, `napi_set_instance_data`) in a `PendingNapiFinalizer` list shared between `NapiState` and `Env` - Call tracked finalizers in LIFO order during `MainWorker` shutdown while V8 is still alive with a proper `HandleScope`, matching Node.js's `RefTracker::FinalizeAll()` behavior - When finalizers fire naturally via GC weak callbacks, they deregister from the tracker to avoid double-calling This fixes native addons like DuckDB that rely on C++ destructor cleanup (e.g. WAL checkpointing) during process exit. Previously these finalizers only ran via V8 GC weak callbacks, which never fire for objects still reachable at exit. Closes #27468 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Author
Parents
Loading