You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
0 commit comments