Skip to content

Commit 20aae9d

Browse files
committed
src: fix closing weak HandleWraps on GC
In 0af62aa, this was overlooked, with it possibly leading to hard crashes. Refs: nodejs#29317
1 parent ac59dc4 commit 20aae9d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/handle_wrap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ void HandleWrap::Close(Local<Value> close_callback) {
7272
if (state_ != kInitialized)
7373
return;
7474

75-
CHECK_EQ(false, persistent().IsEmpty());
7675
uv_close(handle_, OnClose);
7776
state_ = kClosing;
7877

79-
if (!close_callback.IsEmpty() && close_callback->IsFunction()) {
78+
if (!close_callback.IsEmpty() && close_callback->IsFunction() &&
79+
!persistent().IsEmpty()) {
8080
object()->Set(env()->context(),
8181
env()->handle_onclose_symbol(),
8282
close_callback).Check();

test/sequential/test-performance-eventloopdelay.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --expose-gc
12
'use strict';
23

34
const common = require('../common');
@@ -97,3 +98,5 @@ const {
9798
}
9899
spinAWhile();
99100
}
101+
102+
process.on('exit', global.gc);

0 commit comments

Comments
 (0)