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