We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5cdeb76 commit 3ab223dCopy full SHA for 3ab223d
src/js_native_api_v8.cc
@@ -374,8 +374,11 @@ class Reference : public RefBase {
374
inline void Finalize(bool is_env_teardown = false) override {
375
// During env teardown, `~napi_env()` alone is responsible for finalizing.
376
// Thus, we don't want any stray gc passes to trigger a second call to
377
- // `Finalize()`, so let's reset the persistent here.
378
- if (is_env_teardown) _persistent.ClearWeak();
+ // `Finalize()`, so let's reset the persistent here if nothing is
+ // keeping it alive.
379
+ if (is_env_teardown && _persistent.IsWeak()) {
380
+ _persistent.ClearWeak();
381
+ }
382
383
// Chain up to perform the rest of the finalization.
384
RefBase::Finalize(is_env_teardown);
0 commit comments